我收到此错误:
查询表达式' 10'
中的语法错误(缺少运算符)
我的代码:
string MySQL3 = "Update RegisterDatabase Set ";
MySQL3 += "uName ='" + Request.Form["uname"] + "', pName ='" + Request.Form["pname"] + "', idNumber ='" + Request.Form["id"] + "', age =" + Request.Form["age"] + "', pass ='" + Request.Form["pass"] + "', email ='" + Request.Form["email"] + "'";
MySQL3 += " Where uName ='" + Session["uname"];
System.Data.OleDb.OleDbCommand o_command3 = new System.Data.OleDb.OleDbCommand(MySQL3, o_con);
o_con.Open();
o_command3.ExecuteNonQuery();
o_con.Close();
BTW我知道我的代码很容易受到SQL注入攻击,但这适用于我的学校项目,所以它并不重要。
答案 0 :(得分:0)
问题出在这里
age =" + Request.Form["age"] + "+ "'
应该是
age =" + Request.Form["age"] + ", pass =
和
MySQL3 += " Where uName ='" + Session["uname"];
应该是
MySQL3 += " Where uName ='" + Session["uname"] +"'";
答案 1 :(得分:0)
MyClass
试试上面的代码。 希望这会有所帮助。