0
我想用下面的代碼填充存儲過程的gridview,但最新發生的是gridview沒有顯示任何東西。c#gridview不填充存儲過程sql
SqlConnection myConnectiona = new SqlConnection("user id=HOME-PC\\HOME;" +
"password=password;server=HOME-PC\\SQLEXPRESS;" +
"Trusted_Connection=yes;" +
"database=tabrem; " +
"connection timeout=30");
SqlCommand pro = new SqlCommand("[dbo].[doctor]", myConnectiona);
pro.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(pro);
DataTable dt = new DataTable();
try
{
myConnectiona.Open();
da.Fill(dt);
dataGridView1.DataSource = dt;
}
catch (Exception w)
{
throw;
}
finally
{
if (myConnectiona.State == ConnectionState.Open)
myConnectiona.Close();
}
如果你手動運行它的SP返回的東西嗎? – ChrisBint
如果你在這一行刪除一個斷點:'da.Fill(dt);',你能看到你的結果集嗎? –