我已经通过MS Access创建了一个软件,但是如果我想更新表格中的行显示错误Syntax error in UPDATE statement.
这是我的代码。
string cmdString = "UPDATE users SET username=@username,password=@password,email=@email WHERE ID=@ID";
cmd.Parameters.Add("@username", OleDbType.VarChar, 100).Value = dataGridView1.Rows[RowIndex].Cells[1].Value;
cmd.Parameters.Add("@password", OleDbType.VarChar, 100).Value = dataGridView1.Rows[RowIndex].Cells[2].Value;
cmd.Parameters.Add("@email", OleDbType.VarChar, 100).Value = dataGridView1.Rows[RowIndex].Cells[3].Value;
cmd.Parameters.Add("@ID", OleDbType.Integer, 100).Value = dataGridView1.Rows[RowIndex].Cells[0].Value;
cmd.CommandText = cmdString;
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();