当前位置:编程学习 > C#/ASP.NET >>

密码修改功能异常

菜鸟问题:无论输入什么,都只会显示"原密码有误!" 将所有条件语句屏蔽,然后执行,正确输入就可以改密码,请高手指点指点!小弟刚学,不胜感激!


 if (this.txt原密码.Text.Trim() != Login.pwd)
            {
                MessageBox.Show("原密码有误!");
                return;
            }

            if (this.txt新密码.Text.Trim() == "")
            {
                MessageBox.Show("新密码不能为空!");
                return;
            }

            if (this.txt新密码.Text != this.txt确认新密码.Text)
            {
                MessageBox.Show("确认密码与新密码不一致,请重新输入!");
                return;
            }
            try
            {
                SqlConnection thisConnection = new SqlConnection("integrated security=SSPI;data source=.;persist security info=False;initial catalog=student");
                thisConnection.Open();
                SqlCommand cmd = new SqlCommand("UPDATE 学生表 set 密码='" + this.txt新密码.Text.Trim() + "' where 学号='" + Login.uid + "'", thisConnection);
                SqlDataReader myreader = cmd.ExecuteReader();
                //this.Close();
                thisConnection.Close();
                MessageBox.Show("修改成功!", "提示");
               
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }

--------------------编程问答-------------------- 看看this.txt原密码.Text.Trim() , Login.pwd的值
  
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 

http://feiyun0112.cnblogs.com/ --------------------编程问答-------------------- 都没有问题啊……就是在if (this.txt原密码.Text.Trim() != Login.pwd) 
            { 
                MessageBox.Show("原密码有误!"); 
                return; 
            }就无法继续下去了。无论密码输入正确与否,都会显示"原密码有误!"  --------------------编程问答-------------------- if (this.txt原密码.Text.Trim() != Login.pwd.ToString()) 试试
--------------------编程问答-------------------- 设断点先看你登陆密码是不是有值的 --------------------编程问答-------------------- 你的密码是不是取错了?是不是取的全是"********",debug一下看看,应就一目了然了
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,