覆盖数据库中的现有值 [英] OverWrite the existing value in the database

查看:55
本文介绍了覆盖数据库中的现有值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!这是我目前正在研究的一个项目...它在做什么,它要求用户提供登录信息(例如用户名和密码),并用数据库中的值进行验证.以及是否与数据库中的值匹配它打开第二个窗口,在该窗口中,用户可以更改密码.....
我到目前为止所做的只是盯着一个名为DB.mdf的数据库,该数据库具有一个名为userInfo_table的表并与程序连接...我能够验证用户的用户名和密码并打开第二个窗口,但是现在我无法覆盖数据库中的密码值,以便从下一次用户登录时起,用户必须插入新密码...
数据库详细信息...
数据库名称-DB.mdf
表名-usrInfo_table
列-用户名和密码

请下载并评估该porgram ...
http://www.quickfilepost.com/download.do?get=ed85ecd13317881e3d51a4abd335bf74

Hello! Here a project on which I am working on currenty...what it does is it asks for the login information like username and password from user and verifies it with the values in the database..and if it matches with the values in the database it opens 2nd window where It gives user to change password.....
What I have done till now is stared a database named DB.mdf which has a table named userInfo_table and connected with the program...I am able to validate the user name and password from the user and open the second window but now I cant overwrite the value of password in the database so that from next time when user Logins user have to insert the new password...
Database details...
database name -- DB.mdf
Table name -- usrInfo_table
Columns -- Username and Password

Please download and evaluate this porgram...
http://www.quickfilepost.com/download.do?get=ed85ecd13317881e3d51a4abd335bf74

推荐答案

由于您已经验证了用户,因此我假设您熟悉ADO.网.与验证用户名和密码的过程类似.唯一的区别是,要更改用户密码,您将需要执行更新命令.像这样的东西:
Since you have already verified the user, I assume you are familiar with ADO.Net. You have go on the similar lines as you did for validating user name and password. Only difference being, for changing the password for the user, you would need to execute an update command. Something like this:
Update yourTable
set Password = ''changedPassword'' 
where userName=''currentUserName''


在这种情况下,您应该阅读ADO.Net上的书籍/教程. .Net框架提供了许多类来在数据库中执行更新.在您的情况下,您将需要OleDbConnectionOleDbCommand类.除此之外,您还需要使用CommandParameters.看看这些,您就可以解决.
In that case you should read a book/tutorial on ADO.Net. .Net frameworkd provides a lot of classes to perform updates in the database. In your case, you would need OleDbConnection and OleDbCommand classes. Along with that you would also need to use CommandParameters. Have a look a these and you can work through.


1.在您的项目中添加一个类文件(.cs)
2.以该.cs文件的登录形式创建一个对象
3.声明变量,如
公共静态字符串strUsername;"在.cs文件中
4.用户登录时,单击按钮(登录按钮),在该变量中分配用户名("strUsername")
5.以第二种形式(用于更改密码形式)在此处也为.cs文件创建对象
6.编写更新查询,例如"update usrInfo_table set password =''+ txtpwd.text +"'',其中username =''"+ objcs.strUsername +"''"

objcs-> cs文件的对象



问候
S.Murugesan
软件工程师
Gratiff解决方案和系统
1.add one class file(.cs) in your project
2.create a object in login form for that .cs file
3.declare the variable like
"public static string strUsername;" in .cs file
4.while user login,on button click(login button) assign the username in that variable("strUsername")
5.in second form(for change the password form) here also create object for .cs file
6.write update query like"update usrInfo_table set password=''"+ txtpwd.text+"'' where username=''" + objcs.strUsername +"''"

objcs-->objects of cs file



Regards
S.Murugesan
Software Engineer
Gratiff solution and systems


这篇关于覆盖数据库中的现有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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