So far inthis chapter, you have seen how to update a database and how to add transactions to ensure data integrity. All of that is fine as far as it goes, but nothing you’ve done so far to update the database takes advantage of the DataSet object, which you will remember is the keystone of ADO.NET.
If you are using the DataSet object to retrieve data and pass it from tier to tier within your application, you would also like to manipulate that data within the dataset and push the changes back to the database. To make this more sophisticated model of data updating work, you will need to take advantage of the advanced capabilities of the DataSet and the DataAdapter classes, and you’ll need to understand how they in turn use the Command and Connection objects to mediate between the dataset and the database itself.
As explained in Chapter 11, the DataSet object interacts with the database through a DataAdapter object. Until now, you’ve created the data adapter by passing in a command string and a connection string to the DataAdapter object’s constructor and then calling the Fill method. It turns out that Fill interacts with the database by creating a command object on your behalf and assigning that command object to the SelectCommand property of the DataAdapter object.
Each SqlDataAdapter object has four command properties (SelectCommand, UpdateCommand, InsertCommand, and DeleteCommand), each of which takes an object of type ...