日期:2014-05-17  浏览次数:20852 次

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("密码错误"); }
            }
   &