Using a SqlCommandBuilder to Generate Updating Logic

The ADO.NET object model not only allows you to define your own updating logic, but it also provides dynamic updating logic generation similar to that of the ADO cursor engine, using the SqlCommandBuilder class. If you instantiate a SqlCommandBuilder object and associate it with a SqlDataAdapter object, the SqlCommandBuilder will attempt to generate updating logic based on the query contained in the SqlDataAdapter object’s SelectCommand.

To demonstrate how the SqlCommandBuilder works, I’ll use it to generate updating logic for our sample code that queries the Order Details table. The following code snippet instantiates a SqlCommandBuilder, supplying a SqlDataAdapter in the constructor. It then ...

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.