In this article I will explain the following ADO.NET concepts: DataTable, DataSet, DataReader and DataAdapter. Also, learn about some differences between these ADO.NET concepts.
DataTable:
- DataTable represents a single table in a database.
- In this show row and column.
- DataSet is a collection of data tables.
- In this store data record.
DataTable representation in .aspx.cs code,
- protected void BinddataTable()
- {
- SqlConnection con = new SqlConnection("your database connection string");
- con.Open();
- SqlCommand cmd = new SqlCommand("Write your query or procedure", con);
- SqlDataAdapter da = new SqlDataAdapter(cmd);
- DataTable dt = new DataTable();
- da.Fill(dt);
- grid.DataSource = dt;
- grid.DataBind();
- }
- DataSet can hold multiple tables at a time.
- DataSet allow data access to easily read or write data operations in / from the database.
- DataSet data stores in local system.
- DataSet hold multiple rows at a time.
- DataSet use more memory.
- DataSet maintain relation.
- DataSet bind data from the database.
DataSet representation in .aspx.cs code,
- protected void BindDataSet()
- {
- SqlConnection con = new SqlConnection("your database connection string ");
- con.Open();
- SqlCommand cmd = new SqlCommand("Write your query or procedure ", con);
- SqlDataAdapter da = new SqlDataAdapter(cmd);
- DataSet ds = new DataSet();
- da.Fill(ds);
- grid.DataSource = ds;
- grid.DataBind();
- }

Santhakumar MunuswamyPosted Oct 18, 2015, 3:20 AM
Good one
Priyaranjan K SPosted Oct 14, 2015, 12:20 PM
Good One ji ..
Mukesh KumarPosted Oct 14, 2015, 1:29 AM
Greate work, thanks for sharing
Rajeesh MenothPosted Oct 14, 2015, 12:27 AM
Nice One !!
Nilesh JadavPosted Oct 14, 2015, 12:08 AM
Nice one sir !!
Harshad PansuriyaPosted Oct 13, 2015, 11:55 PM
Nice one
Gowtham KPosted Oct 13, 2015, 10:40 PM
Good one
Ravi PatelPosted Oct 13, 2015, 9:30 PM
good article
Sujeet SumanPosted Oct 13, 2015, 1:56 PM
Nice Article................