不知是什么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;