asp.net修改密码后,数据库的内容已经改了,但是新密码登不上去,旧密码却可以,求助!!!
string sql_update = "update login set u_psd='"+ NewPassword.Text+"'where u_name='"+Session["user_name"]+"'";
string sqladd = "select * from yjd_login where u_name='"+Session["user_name"]+"' and u_psd='" + Password.Text.Trim() + "'";
SqlConnection conn = new SqlConnection("server=。;database=YJD_PDR;user id=sa;password=123123");
SqlCommand commd = new SqlCommand(sqladd, conn);
conn.Open();
int result=0;
if (commd.ExecuteScalar() != null)
{
result = Convert.ToInt32(commd.ExecuteScalar().ToString());
if (result > 0)
{
SqlCommand cmd_update = new SqlCommand(sql_update, conn);
int update_row = cmd_update.ExecuteNonQuery();
if (update_row > 0)
{ Response.Write("修改成功");
conn.Close();
Session.Abandon();
Cache.Clear();
Request.Cookies.Clear();
Response.Redirect("login.aspx");
}
else { Response.Write("密码未修改"); }
}
else { Response.Write("密码错误"); }
}
else Response.Write("密码错误");
conn.Close();
return;
[解决办法]
先学会三层在来写这个功能,要不然代码看起来很乱。
[解决办法]
单步调试,看登录时取的账号和密码究竟是什么,从哪里来的。
[解决办法]
先看看代码有没有错误,再有就是楼上说的了,加断点,自己慢慢调试,细心就好
[解决办法]
你用了2张不一样的表
[解决办法]
调试一下,很容易找到问题的。
要不就是cache?
[解决办法]
如果都是yjd_login,你看下登录的代码是不是有问题。你确定都是连的yjd_login这个表?