DEV Community

Steve Mak
Steve Mak

Posted on

Learning Notes of ADO.NET

Primary Objects

(Ref: https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/data-providers)

  1. Connection - Provides connectivity to a data source.
  2. Command - Enables access to database commands to return data, modify data, run stored procedures, and send or retrieve parameter information.
  3. DataReader - Provides a high-performance stream of data from the data source.
  4. DataAdapter - Provides the bridge between the DataSet object and the data source. The DataAdapter uses Command objects to execute SQL commands at the data source to both load the DataSet with data and reconcile changes that were made to the data in the DataSet back to the data source.
  5. DataSet - Contains a collection of one or more DataTable objects consisting of rows and columns of data, and also primary key, foreign key, constraint, and relation information about the data in the DataTable objects. (DataTable, DataView, DataRow)

DataReader or DataSet

Use a DataSet to do the following:

  • Cache data locally in your application so that you can manipulate it. If you only need to read the results of a query, the DataReader is the better choice.
  • Remote data between tiers or from an XML Web service.
  • Interact with data dynamically such as binding to a Windows Forms control or combining and relating data from multiple sources.
  • Perform extensive processing on data without requiring an open connection to the data source, which frees the connection to be used by other clients.

Top comments (0)