latest Post

What is the DataAdapter Object in ADO.NET?

What is the DataAdapter Object in ADO.NET?

A Data Adapter represents a set of data commands and a database connection to fill the dataset and update a SQL Server database.

A Data Adapter contains a set of data commands and a database connection to fill the dataset and update a SQL Server database. Data Adapters form the bridge between a data source and a dataset.

Data Adapters are designed depending on the specific data source. The following table shows the Data Adapter classes with their data source.
Provider-Specific Data Adapter classesData Source
SqlDataAdapterSQL Server
OledbDataAdapterOLE DB provider
OdbcDataAdapterODBC driver
OracleDataAdapterOracle
A Data Adapter 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.
Example: 
  1. SqlDataAdapter da=new SqlDataAdapter("Select * from  
  2. Employee", con);  
  3. da.Fill(ds,"Emp");  
  4. bldr =new SqlCommandBuilder(da);  
  5. dataGridView1.DataSource = ds.Tables["Emp"]; 

About Mallikarjun A

Mallikarjun A
Recommended Posts × +

0 comments:

Post a Comment