Summary

In this chapter we took a close look at the DataAdapter, which is a principal ADO.NET object. The DataAdapter is the bridge between the disconnected world of the DataSet and its associated objects and the connected world of the .NET Data Provider objects that actually connect and communicate with a physical data source.

The DataAdapter is used to fill a DataSet with data from a data source, using either explicit commands or stored procedures. The DataAdapter also provides automatic updating to the data source of the changes made to the DataSet, while also allowing for complete customization of the commands to be used for the Insert, Update, and Delete operations against the data source.

Questions and Answers

Q1:

Sometimes I want to be able to create and populate a set of data records programmatically and then update the database with this data. When I tried this with ADO 2.X, I could create the data records, but I was unable to update the database. Is there any change in this area in ADO.NET?

A1:

You bet there is! As we discussed in Chapter 5, the DataSet is a container for data, but it doesn't know or care where that data came from. When you want to update a database with the data from a DataSet, just connect it to an appropriately configured DataAdapter, call the DataAdapter's Update method, and the database will be updated. This is true even if the DataSet data is created programmatically, rather than by using the DataAdapter's Select command to fill the DataSet. When you're ready to push the DataSet's data into a data source, connect it to a properly configured DataAdapter and perform the update.



Database Access with Visual Basic. NET
Database Access with Visual Basic .NET (3rd Edition)
ISBN: 0672323435
EAN: 2147483647
Year: 2003
Pages: 97

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