当前位置: 代码迷 >> ASP.NET >> asp.net access update 语句 语法异常 质疑
  详细解决方案

asp.net access update 语句 语法异常 质疑

热度:7927   发布时间:2013-02-25 00:00:00.0
asp.net access update 语句 语法错误 质疑 求助
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中参数须用@参数名 这种形式的
------解决方案--------------------------------------------------------
探讨
C# code

OleDbConnection conn = new OleDbConnection(Service.connectionString);
string updateSqlForName = "update manager set username=?, password=? where id=?";
……

------解决方案--------------------------------------------------------
username=@username 或者 username='"+ tb_newusername.Text.ToString() +"'
  相关解决方案