Update requires a valid UpdateCommand when passed DataRow collection with modified rows

Sam picture Sam · Feb 26, 2009 · Viewed 53.3k times · Source

So I had this working last week. At least, I thought I did! DataGridView Update

Then I start working on the project again today and am getting

Update requires a valid UpdateCommand when passed DataRow collection with modified rows.

On

scDB.SSIS_Configurations_StagingDataTable table = (scDB.SSIS_Configurations_StagingDataTable)stagingGrid.DataSource;
myStagingTableAdapter.Update(table);

The StagingTableAdapter has an additional query which takes 'filter' as a parameter. That was used to fill the DataGridView. In the wizard for creating that query I see 'update was generated'. I see that most posts with this error require that an update statement be generated with a command builder. What do I do?

Answer

Jason picture Jason · Jun 13, 2011

This message will also be displayed caused when you do not have a primary key defined on the table you are updating.