Saturday 17 December 2011

The relationshipe between Connection,Command,DataAdapter,DataSet Objects

 
SqlConnection scon = new SqlConnection("database=StudentDB;trusted_connection=yes");
SqlCommand scmd = new SqlCommand("select* from StudentInfoTable", scon);
SqlDataAdapter sda = new SqlDataAdapter(scmd);
DataSet ds = new DataSet();
sda.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();

// And finally  giving the object of DataSet to the Gridview having ID="Gridview1"  last two line to bind the Dataset to the Gridview.

No comments:

Post a Comment