- C# code
OleDbConnection conn = new OleDbConnection(Service.connectionString); string updateSqlForName = "update manager set username=?, password=? where id=?"; OleDbCommand cmd = new OleDbCommand(updateSqlForName, conn); cmd.Parameters.Add(new OleDbParameter("@username", OleDbType.VarWChar, 50)).Value = tb_newusername.Text.ToString(); cmd.Parameters.Add(new OleDbParameter("@password", OleDbType.VarWChar, 50)).Value = tb_newpass.Text.ToString(); cmd.Parameters.Add(new OleDbParameter("@id", OleDbType.VarWChar, 50)).Value = Session["ManagerId"].ToString(); conn.Open(); cmd.ExecuteNonQuery(); Response.Write("<script>alert('修改成功,请您重新登录!')</script>"); AbandonSession(); conn.Close(); conn.Dispose();
提示Update 语法错误
帮忙解决一下,谢谢
------解决方案--------------------------------------------------------
把?换成@username之类的
------解决方案--------------------------------------------------------
在.net中参数须用@参数名 这种形式的
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
username=@username 或者 username='"+ tb_newusername.Text.ToString() +"'