我整个周末都在看这段代码。我知道有数据,我可以通过其他查询提取它,但 GridView 不会显示和填充。建议?
string sqlSelection =
"SELECT * FROM [COMPANY].[dbo].[parking] ";
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["DATACONNECTION"].ToString());
//This connection works in MSSMS and in other pages I have on the same server
SqlDataAdapter sda = new SqlDataAdapter(sqlSelection, cn);
SqlCommandBuilder scb = new SqlCommandBuilder(sda);
DataTable dTable = new DataTable();
sda.Fill(dTable);
//debug shows: dTable <not set>
GrdDynamic.Visible = true;
GrdDynamic.DataSource = dTable;
GrdDynamic.DataBind();