DataSet: DataSet. It generally contains multiple able. When used, dataset ["table name"] gets the DataTable
DataTable: data table.
I:
SqlDataAdapter
Da = new
SqlDataAdapter (cmd );
DataTable
Dt = new
DataTable ();
Da. Fill (dt );
-----------------
Directly place the data results
Datatable,
II:
SqlDataAdapter
Da = new
SqlDataAdapter (cmd );
DataSet
Dt = new
DataSet ();
Da. Fill (dt );
----------------
The data result is put into dataset. If you want to use the datatable, you can do this: dataset [0]
More common usage:
SqlDataAdapter
Da = new
SqlDataAdapter (cmd );
DataSet
Dt = new
DataSet ();
Da. Fill (dt, "table1 ");
In this way, the datatable is obtained:
Dataset ["table1"]
Specific applications:
SqlConnection con = new SqlConnection ("server =.; database = StuCourseDb1; uid = sa; pwd = xhz ;");
SqlDataAdapter sda = new SqlDataAdapter ("select * from student", con );
DataSet ds = new DataSet ();
Sda. Fill (ds, "StuTable ");
This. GridView1.DataSource = ds. Tables ["StuTable"];
This. GridView1.DataBind ();
Ds. Dispose ();
Con. Close ();
Con. Dispose ();