ADO .NET and Datasets



ADO.NET is a library of classes providing data access services and functionalities to the .NET programmer writing managed code. It provides consistent access to data sources such as Microsoft® SQL ServerT, as well as other data sources exposed through OLE DB and XML; the supported operations fall into one of the three categories: retrieval, manipulation, or data updating.
The model of the ADO.NET for data access supposes the opening of a connection, getting data or performing an operation, and then closing the connection. The two basic strategies for working with the model exist. One strategy is store data in a dataset, which is an in-memory cache of records with which it can be worked even after the disconnection from the data source. An alternative strategy is to perform operations directly against the database, by using a data command object that includes an SQL statement or a reference to a stored procedure. The result can be then fetched using one of the data-reader class instances. Out of the advantages of this strategy we name here: the extra functionalities ( in some cases only ) , and the more control over execution it provides.

The advantages of Datasets are : the support for working with multiple tables (a dataset can contain many tables and each can be manipulated independently or through its relationships with the other tables in the dataset ) , manipulating data from multiple sources, maintaining records for reuse ( as we have stated, datasets retain the information in an in-memory cache after the connection to the database has been closed ), and last but not least ease of programming. For a Windows Form application, working with datasets is recommended over the traditional way of operating directly on the database for every operation. The reasons for this are that in a windows form application, data is not discarded so often as in a web application ( where almost each operation implies discarding and again querying against the database ) and also Windows Forms applications traditionally offer data-access scenarios that can take advantage from maintaining a cache of records, like displaying records one by one in a data grid.