Home > DeveloperSection > Articles > DataAdapter

DataAdapter


ADO.Net ADO.Net 
Ratings:
0 Comment(s)
 3623  View(s)
Rate this:

DATA ADAPTER

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");

//open connection      

con.Open();

//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
ad.Fill(dt);

  //close the connection

con.Open();


Don't want to miss updates? Please click the below button!

Follow MindStick