0

I was trying to update the data to the access database while displaying the same data in datagridview. I was using binding source and table adapter for that purpose. I keep receiving this "Update requires a valid InsertCommand when passed DataRow collection with new rows" error. It is a multiple form project and the same code is used in another form and it works fine. What could be the source of this error and how to get rid of it?

Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
    Try
        UsersBindingSource.EndEdit()
        UsersTableAdapter.Adapter.Update(MRStudioDataSet3.Users)
        st = 1
        MessageBox.Show("Changes Saved")
    Catch exc As System.Data.ConstraintException
        MessageBox.Show("Username Already Taken", "Username Uniqueness Violation", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        UsersBindingSource.RemoveCurrent()
    End Try
End Sub
hcoder
  • 103
  • 11
  • You may need to create an `OleDbCommandBuilder` object that is associated with your `UsersTableAdapter`. – Gord Thompson Mar 25 '16 at 01:33
  • 1
    Question, does the table in question have a primary key that auto-increments, if there is not one this can cause failure? See this post http://stackoverflow.com/questions/588361/update-requires-a-valid-updatecommand-when-passed-datarow-collection-with-modifi – Karen Payne Mar 25 '16 at 01:36

0 Answers0