What is the DataAdapter Object in ADO.NET?

Technology CommunityCategory: ADO.NETWhat is the DataAdapter Object in ADO.NET?
VietMX Staff asked 3 years ago

DataAdapter is used to retrieve data from a data source and populate tables within a DataSet. Data Adapters form the bridge between a data source and a dataset. The DataAdapter also resolves changes made to the DataSet back to the data source. The DataAdapter uses the Connection object of the .NET Framework data provider to connect to a data source, and it uses Command objects to retrieve data from and resolve changes to the data source.

DataAdapter supports mainly the following two methods:

  • Fill(): The Fill method populates a dataset or a data table object with data from the database. It retrieves rows from the data source using the SELECT statement specified by an associated select command property. The Fill method leaves the connection in the same state as it encountered before populating the data.
  • Update(): The Update method commits the changes back to the database. It also analyzes the RowState of each record in the DataSet and calls the appropriate INSERT, UPDATE, and DELETE statements.