SqlConnection con = DB.getConnection();
SqlDataAdapter dad = new SqlDataAdapter(new SqlCommand("select pid,pname,psex from person", con)); //构造DataAdapter
DataSet dst = new DataSet(); //构造DataSet
dad.Fill(dst); //用DataAdapter填充DataSet
con.Close();
dgrdPerson.DataSource=dst.Tables[0];//DataGrid指定数据源为DataTable
dgrdPerson.DataBind(); //DataGrid数据绑定
SqlDataAdapter dad = new SqlDataAdapter(new SqlCommand("select pid,pname,psex from person", con)); //构造DataAdapter
DataSet dst = new DataSet(); //构造DataSet
dad.Fill(dst); //用DataAdapter填充DataSet
con.Close();
dgrdPerson.DataSource=dst.Tables[0];//DataGrid指定数据源为DataTable
dgrdPerson.DataBind(); //DataGrid数据绑定