Questions That Should Be Asked More Frequently

Q

When I try to submit changes using a TableAdapter’s Update method, I get an exception stating that "Update requires a valid UpdateCommand when passing a DataRow collection with modified rows." What went wrong?

A

This is the same exception you would receive if you called the Update method on a SqlDataAdapter without having supplied updating logic. The TableAdapter Configuration Wizard does not display any warnings or errors if it fails to generate the logic required to submit changes to the database. There are three common scenarios where the TableAdapter lacks updating logic:

  • You neglected to include the primary key column or columns in the TableAdapter’s query.

  • The table you used in the TableAdapter ...

Get Programming Microsoft® ADO.NET 2.0 Core Reference, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.