Hello all,
I'm trying to understand the process that is behind the bindingnavigator.bindingsource.AddNew() method because it has been giving me some strange results when trying to add a record to the database table. I'm sure I'm missing a step I need to take. Help to understand would be greatly appreciated.
What I Have:
An Access database table named StudentList, a Visual Studios C# form with fields bound through a bindingsource and bindingnavigator. Whenever I update an existing student's record:
*change fields, press 'Save Record'*
//validate fields
...
studentListBindingSource.EndEdit();
studentListTableAdapter.Update(sLCStudentListDataSet.StudentList);
the database table is updated immediately, everything is fine. But when I try to add a new record:
bindingNavigatorStudentGI.BindingSource.AddNew();
ClearStudentForm();
*the number of records on the navigator increases by one, the fields are cleared for new data, I enter in new data, I press 'Save Record'*
//validate fields
...
studentListBindingSource.EndEdit();
studentListTableAdapter.Update(sLCStudentListDataSet.StudentList);
the database table is not updated (though no exceptions are thrown). There must be a step I am missing that would commit the new record to the datatable/tableadapter so that it would update the database. In trying to figure it out I have found that running the AddNew() method again will commit the row to the datatable but without the ability to look inside the AddNew() method, I'm not sure what it did.
Thank you for your help.