我一直在尝试从 GRIDVIEW 将数据更新到 MSACCESS 数据库。但是在执行 ExecuteNonQuery 语句时,我收到一个错误,即 SYNTAX ERROR IN UPDATE STATEMENT。请帮助我..我的问题可能与几个人发布的问题相似..但我的代码与其他人的不同..请快速响应...在下面的代码中,这是 cmd.ExecuteNonQuery 行(); 我在哪里收到错误...请帮助我
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
OleDbConnection con = new OleDbConnection(constr);
con.Open();
string name = GridView1.DataKeys[e.RowIndex].Values["SName"].ToString();
TextBox day = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox1");
string com = "update enroll set Day = '?' where SName = '?'";
OleDbCommand cmd = new OleDbCommand(com, con);
cmd.Parameters.AddWithValue("@Day", day.Text.ToString());
cmd.Parameters.AddWithValue("@SName", name.ToString());
cmd.ExecuteNonQuery();
con.Close();
Label3.ForeColor = Color.Green;
Label3.Text = name + " Details Updated successfully";
GridView1.EditIndex = -1;
}