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

This was very annoying till i found out that it was due to my data which was imported into SQL Server from MS Acccess. All the primary keys were dropped and hence the Update command was failing.

The tips:

  • Add the approriate primary and foreign key constraints.
  • You also need to change the connection string in your app.config and add MultipleActiveResultSets=True
  • Also, there is one more thing you can do to fix this if problem persist. Go to the dataset designer(assuming you have typed dataset) and then right click adaptor, select configure and then select advance options. Make sure the Referesh the data table options is NOT ticked. I had this ticket and until i unticked it, the first two fixtures didn’t solve my problem.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s