Data Adapter serves a bridge between dataset and data source for retrieving and saving data from the database. The data Adapter provides this bridge by mapping fill which changes the data in dataset to make the data in data source.
Data Adapters can be created by using;
· Data Adapters wizards
· Using solution explorer.
· Using .net classes in the code
Data Adapters is a powerful tools which:
· Creates data connection
· Invoke the command
· Fill the dataset in asp.net application with data from database.
Data Adapter has following properties to execute the records from the database like Select Command, Insert Command, and Delete Command.
The following example shows data Adapter in c#.
//these lines are for creating a new connection by passing server name,uid,password and name of the database as here mind.
SqlConnection con = new SqlConnection("server=abc-pc1\\sqlexpress; uid=sa; password=sa; database=mind");
//create a data adapter and invoking the command.
SqlDataAdapter ad = new SqlDataAdapter("select * from Employee", con);
//creating datatable object
Datatable dt = new DataTable();
//use dataadapter to fill data table
//close the connection