C#-在c#.net中Access更新的问题,求解答
上面是我写的,错误提示是“至少一个参数没有被指定值。 ”
OleDbCommand cmd = new OleDbCommand("select * from [bin_manage] where password='" + MD5passwd + "' and username=" + Session["admin"], myConn);
行 35: OleDbDataReader da = cmd.ExecuteReader();
求解答
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于粗心,后来我改成了这样,代码如下:
protected void bin_reg_click(object sender, EventArgs e)
{
string MD5passwd;
MD5passwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password.Text, "MD5");
string connstr = "provider=microsoft.jet.oledb.4.0;data source=" + Server.MapPath("App_Data/my_web.mdb");
OleDbConnection myConn = new OleDbConnection(connstr);
myConn.Open();
OleDbCommand cmd = new OleDbCommand("select count(*) as icount from [bin_manage] where [username] ='" + Session["admin"].ToString() + "' and [password] ='" + MD5passwd + "'", myConn);
int i = 0;
i = (int)(cmd.ExecuteScalar());
if (i >= 1)
{
string MD5passwd1;
MD5passwd1 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password1.Text, "MD5");
OleDbCommand upadte_cmd = new OleDbCommand("UPDATE [bin_manage] set [password] ='" + MD5passwd1 + "', [email] ='" + email.Text + "' where [username] ='" + username.Text + "'", myConn);
upadte_cmd.ExecuteNonQuery();
myConn.Close();
Response.Write("https://www.wenjiangs.com/wp-content/uploads/stackoverflow/202207/<script>alert('ok');location='index.aspx';</script>");
}
else
{
myConn.Close();
Response.Write("https://www.wenjiangs.com/wp-content/uploads/stackoverflow/202207/<script>alert('sorry , original password error !');history.go(-1)</script>");
}
}
username=后面不是应该加单引号吗