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


DataSet has been designed for an offline container that means it always works on disconnected dataset contains data tables collections and their relationships it represent a complete set of data including tables that contain tables rows and constraints. Build and fill each data table in a dataset with data from a data source using data adapter.

Dataset is the collection of the DataTable as figure:


The following example shows DataAdapter 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      


//create a data adapter and invoking the command.

SqlDataAdapter ad = new SqlDataAdapter("select * from Employee", con);

//creating dataset object

DataSet ds=new DataSet();

ad.fill(ds)//use dataadapter to fill data table

 //close the connection


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

Follow MindStick