关于OleDBCommand的update问题。
ajou 2004-09-20 06:28:28 try
{
cmd.CommandText = "UPDATE userTable SET Password = @newPassword WHRER userID = @theUserID";
cmd.Parameters.Add(new OleDbParameter("@theUserID", OleDbType.Integer)).Value = UserID;
cmd.Parameters.Add(new OleDbParameter("@newPassword", OleDbType.VarChar, 50)).Value = textBox2.Text.ToString();
cmd.Connection = con;
//MessageBox.Show(cmd.CommandText);
cmd.ExecuteNonQuery();
MessageBox.Show("更改密码成功","提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
con.Close();
}
其中con连接的是本地access的数据库,UserID是主Form传递过来的int值,没有问题。运行时为什么总是提示update语句的语法错误?百思不得其解阿。各位请支招。谢谢。