The DataAdapter Class

Team-Fly team-fly    

 
ADO.NET Programming in Visual Basic .NET
By Steve  Holzner, Bob  Howell

Table of Contents
Chapter 4.   The ADO .NET Class Library


The DataAdapter class contains four Command objects and some methods for populating and updating DataSets from the commands. Essentially, the DataAdapter is a worker class that holds the four Command objects and has the ability to execute the commands and send the results to a DataSet. The DataAdapter knows how to build update, insert, and delete statements from the context of the Select statement provided by the programmer. It also knows how to generate parameter lists. To do this it uses a helper class called the SQLCommandBuilder.

The Fill Method

The Fill method causes the DataAdapter to execute the Command object in the SelectCommand property, generate a DataReader object to obtain the results, then pump the results into a DataTable in a DataSet. This is a real time-saver in that the programmer has to execute only one method. The same results could be obtained by using discrete Command, DataReader and DataTable objects, but Microsoft made it easy by doing the work for you.

The FillSchema Method

Similar to the Fill method, the FillSchema method fills the DataTable's Columns collection, but it does not retrieve any data from the database. This is useful for creating a typed DataSet at design time without wasting resources to retrieve data.

The Update Method

The Update method will take any changes made to a DataSet and post them back to the database. The method uses the UpdateCommand, InsertCommand, and DeleteCommand to do this. The DataAdapter knows how to interrogate the DataSet for what changes to make. In one method, it determines which rows to update, insert, or delete. The Update method uses optimistic concurrency to ensure that multiple users' updates do not interfere with each other.


Team-Fly team-fly    
Top


ADO. NET Programming in Visual Basic. NET
ADO.NET Programming in Visual Basic .NET (2nd Edition)
ISBN: 0131018817
EAN: 2147483647
Year: 2005
Pages: 123

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net