I have a form bound to a dataset and when I change a field and click save I get an error. An edited version of the default code for the save button is below:
Private Sub TblSectionsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TblSectionsBindingNavigatorSaveItem.Click
Try
Me.Validate() Me.TblSectionsBindingSource.EndEdit() Me.TblSectionsTableAdapter.Update(Me._MC2KtoOL.tblSections)MsgBox(
"Update successful") Catch ex As ExceptionMsgBox(
"Update failed") End Try End Sub
I added the try method to catch the error before it errors out. Without the try method the following code line is highlighted:
I get the following code error:
Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
I took for granted that the save button would work with default code but it doesn't. Any ideas Thanks for any help.
-- ADDED:
It's strange because I can click add record, add a record, click save and it saves to the dataset fine with no additional code However, I can't figure out how to pass the update to the back end Access database. It only updates the temporary dataset used by the form. Also, when a record is deleted and the save button clicked it also errors out.