不知是什么grid控件
如果是DataGrid的话,可以这样做:
SqlConnection nwindConn = new SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind");SqlCommand selectCMD = new SqlCommand("SELECT CustomerID, CompanyName FROM Customers", nwindConn);
selectCMD.CommandTimeout = 30;SqlDataAdapter custDA = new SqlDataAdapter();
custDA.SelectCommand = selectCMD;nwindConn.Open();DataSet custDS = new DataSet();
custDA.Fill(custDS, "Customers");nwindConn.Close();dataGrid1.DataSource = custDS;
如果是DataGrid的话,可以这样做:
SqlConnection nwindConn = new SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind");SqlCommand selectCMD = new SqlCommand("SELECT CustomerID, CompanyName FROM Customers", nwindConn);
selectCMD.CommandTimeout = 30;SqlDataAdapter custDA = new SqlDataAdapter();
custDA.SelectCommand = selectCMD;nwindConn.Open();DataSet custDS = new DataSet();
custDA.Fill(custDS, "Customers");nwindConn.Close();dataGrid1.DataSource = custDS;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货