tags:

views:

134

answers:

1

I have made a small SQL database to hold some information about students. I want to save the data to the DB. I've been using the Datasource Wizard to dispaly/manage/save my data. It all works until I need to save. I double-clicked the save button and this is the code that is in there:

this.Validate();
this.studentsBindingSource.EndEdit();
this.studentsTableAdapter.Update(this.studentsDataSet.FirstClass);

Why isn't this working?

+4  A: 

Make sure you set your key field as the primary key in the database. If you forget to mark the field as the primary key, the dataset will populate fine, but you won't be able to update. From what I remember, it either doesn't raise an error or the error isn't clear in some cases.

Aaron
I already set the primary key. It's set to the ID of each student. Good bit of advice though.
Lucas McCoy