private void sdr()
{
SqlConnection conn = new SqlConnection("data source=(local);database=yiqi;uid=monkey;pwd=donkey");
conn.Open();
SqlCommand comm = new SqlCommand("select * from t1", conn);
DataTable dt = new DataTable();
SqlDataReader sdr = comm.ExecuteReader();
dt.Load(sdr);
GridView1.DataSource = dt;
GridView1.DataBind();
conn.Close();
sdr.Dispose();
}
private void sda()
{
SqlConnection conn = new SqlConnection("data source=(local);database=yiqi;uid=monkey;pwd=donkey");
conn.Open();
SqlCommand comm = new SqlCommand("select * from t1", conn);
SqlDataAdapter sda = new SqlDataAdapter(comm);
DataSet ds = new DataSet();
sda.Fill(ds, "t1");
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
conn.Close();
sda.Dispose();
}