articles

Home / DeveloperSection / Articles / DataSet

DataSet

Amit Singh10318 30-Aug-2010

DataSet has been designed for an offline container that means it always works on disconnected mode.ADO.net 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:

DataSet

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 = newSqlConnection("server=abc-pc1\\sqlexpress; uid=sa; password=sa; database=mind");
//open connection      
con.Open();
//create a data adapter and invoking the command.
SqlDataAdapter ad = newSqlDataAdapter("select * from Employee", con);
//creating dataset object
DataSet ds=new DataSet();
ad.fill(ds)//use dataadapter to fill data table
 //close the connection
con.Open();

Updated 23-Sep-2019

Leave Comment

Comments

Liked By