Thursday 17 September 2015

Data Table

Data Table
DataTable represents a single table in the database. It has rows and columns. There is no much difference between dataset and datatable, dataset is simply the collection of datatables.

Example :-
  

 SqlConnection con = new SqlConnection("Data Source=PS-PC\SANTOSH; Database=dbSantoshTest; Integrated Security=true;");
     conn.Open();
     SqlCommand cmd = new SqlCommand("Select Name, Rollno,Branch FROM tblStudent", con);
     SqlDataAdapter adapter = new SqlDataAdapter(cmd);
     DataTable dt = new DataTable();
     adapter.Fill(dt);
     gvDetail.DataSource = dt;
     gvDetail.DataBind();

No comments:

Post a Comment