Skip to content

How to update with TableAdapter

eagle weir

Asked Nov 26, 2006, 9:52 PM EST1 answer
Share
LinkedInX
I try to use TableAdapter to update modified data in DataGridView,with these code: this.wordRankTableAdapter.Update(aBDataSet.WordRank); always cause problem: A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll System.InvalidOperationException: Update requires a valid UpdateCommand when passed DataRow collection with modified rows. at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping) at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping) at System.Data.Common.DbDataAdapter.Update(DataTable dataTable) at WordFrequencyRank.ABDataSetTableAdapters.WordRankTableAdapter.Update(WordRankDataTable dataTable) in C:\Documents and Settings\Administrator\??\WordFrequencyRank\WordFrequencyRank\ABDataSet.Designer.cs:line 740 at WordFrequencyRank.ConfigForm.button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\??\WordFrequencyRank\WordFrequencyRank\ConfigForm.cs:line 48

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    I have solved the problem. I forget to set the Primary key of the data table.
    0