Problem saving changes to table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I receive the following error when trying to update a table after editing.
System.InvalidOperationException was unhandled
Message="Update requires a valid UpdateCommand when passed DataRow
collection with modified rows."
Source="System.Data"

Here is the code:
Private Sub SaveItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TestBindingNavigator.Click
Me.Validate()
Me.TestBindingSource.EndEdit()
Me.TestTableAdapter.Update(Me.DBDataSet.Test)

End Sub

Private Sub Form1tmp_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'DBDataSet.iScanLogin' table.
You can move, or remove it, as needed.
Me.TestTableAdapter.Fill(Me.DBDataSet.Test)

End Sub

In other sections of the program I am able to save changes on other tables
in the same manner without any errors.
What am I doing wrong?
 
Verify that your dataAdapter has a valid Update command. It looks like it's
missing. If you used the Wizard to generate the commands, then there may
have been a problem generating them - make sure you have a Primary key on
the table (or if you're using a commandbuilder, make sur you have a key and
aren't joining tables)
"(e-mail address removed)"
 
I receive the following error when trying to update a table after editing.
System.InvalidOperationException was unhandled
Message="Update requires a valid UpdateCommand when passed DataRow
collection with modified rows."
Source="System.Data"

Seems that you are not providing the required commands to the adapter. It
needs one command for updating, one for deleting and one for inserting, as
required by the changes on the datatable. Try using a CommandBuilder object
to automatically feed the adapter with those commands for you. For complex
scenarios, you can build the commands yourself and "manually" feed the
UpdateCommand, DeleteCommand and InsertCommand properties of the adapter.

HTH,

-Benton
 
iScan

The update code comes in my idea direct from dragging the datasource on the
form, have you maybe copied this withouth creating a new datasource etc.?

Cor
 
Back
Top