更改密码WinForm C# [英] Change Password WinForm C#

查看:110
本文介绍了更改密码WinForm C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在用C#将密码更改为Winform时遇到困难.
我已经有登录页面,可以成功打开第二个表单.
我还具有一个更改密码按钮,该按钮会打开另一个对话框,其中包含三个文本框,一个用于旧密码,一个用于新密码,第三个文本框用于确认新密码.我是否使用Update,SET定向到密码列?还是我仍然可以同时使用UPDATE SET?

Hi i am having difficulty in changing the password to my winform in C#.
I already have the login page successfully opens the second form.
I also have a change password button that opens another dialog with three textboxes, one for the old password, one for the new password and the third textbox is to confirm the new password. Do I use the Update, SET directing to the password column? Or can I still use the UPDATE SET for both?

query = "UPDATE Users SET UserName = 'UserName'" + "Password = 'Password'";



这样可以代替原来的用户名和密码吗?

谢谢.



So this will replace the original user name and password?

Thanks.

推荐答案

除了Prera​​k所说的外,您还可以做
In addition to what Prerak said, you can do
query = "UPDATE Users SET Password='" + Password + "' where UserName = '" + UserName+ "' AND Password='" + OldPassword + "'";


这样,在没有旧密码匹配的情况下,任何人都无法更改密码.


In this way, no one can change the password without the old password matching as well.


您应该实现功能来检查用户输入的旧密码是对还是错,并且还具有验证新密码的功能.密码,然后重新输入新密码是否匹配.如果所有值都为true,则执行更新"命令.

you should implement functionality to check user Entering Old password is right or wrong and also having functionality to validate new password and re-enter new password is matching or not. if all value went true then execute "Update" command.

if(txtnewpassword.Text == txtrenewpassword.Text)
{
query = "UPDATE Users SET Password = ''"+txtnewpassword.Text+"'' where 
UserName =''UserName'' and Password=''"+txtoldpassword.Text+"''";
// Execute query using ExecuteNonQuery function. 
}



您还可以查看给定的问题,并提供一些不错的解决方案.
验证和更改用户密码 [



you can also take a look at given question having some nice solution.
validating and changing a user''s password[^]


应该是这样的
It should be something like this
query = "UPDATE Users SET Password='" + Password + "' where UserName = '" + UserName+ "'";


这篇关于更改密码WinForm C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆