[ Team LiB ] Previous Section Next Section

Chapter 14. DataAdapters

The DataAdapter class serves as a bridge between a disconnected ADO.NET objects and a data source. The DataAdapter retrieves data into a DataSet or a DataTable from a data source using the Fill( ) method. Schema information can be retrieved using the FillSchema( ) method. The DataAdapter updates any changes made to the DataSet or DataTable back to the data source using the Update( ) method.

In simple scenarios, the updating logic that the DataAdapter uses to reconcile changes made to the DataSet can be generated automatically from the query used to retrieve the data by using a CommandBuilder object. For more complex scenarios, custom update logic can be written to control the logic the DataAdapter uses when adding, deleting, and modifying records in the data source in response to changes made to the DataSet. In either case, the updating logic is used when the Update( ) method is called.

Once data is retrieved using the DataAdapter, no information about the connection, database, tables, columns, or any other details about the source of the data is available in the disconnected objects. The data can be persisted or passed between applications without the risk of exposing details about the location or structure of the data source or access credentials used. Figure 14-1 shows the structure of the DataAdapter and the contained classes.

Figure 14-1. The DataAdapter class
figs/adonet_1401.gif
    [ Team LiB ] Previous Section Next Section