-1
我想刷新和更新GridView的所以我用showData()這樣的:附近有語法錯誤Ordertb「
protected void ShowData()
{
con.Open();
string qu = string.Format("SELECT * Ordertb", con);
SqlDataAdapter da = new SqlDataAdapter(qu, con);
DataSet ds = new DataSet();
da.Fill(ds, "ordertbl");
if (ds.Tables["ordertbl"].Rows.Count > 0)
{
GridView1.DataSource = ds.Tables[0];
GridView1.DataSourceID = null;
GridView1.DataBind();
}
con.Close();
}
,但我得到這個錯誤:
Incorrect syntax near 'Ordertb'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'Ordertb'.
您是否嘗試過運行管理工作室查詢?看起來你錯過了'SELECT * FROM Ordertb' – Captain0
你是對的。謝謝。 – mino