需要帮助来更改密码表格(need help to change password form)

   IT问题网   2021-02-19 00:00:00

问 题

大家好,我还是vb.net 2008的新手

i我试着改变密码形式



我想要什么当我点击更改密码按钮然后用户必须输入旧的密码,新的密码并确认新的密码

i am使用sql server 2005而我的朋友告诉我使用sqlcommandbuilder



任何人都可以帮助我?







  imports  system.data.sqlclient 

public class frm_chpass
dim conn as sqlconnection
dim da as sqldataadapter,dt as datatable,dtv 作为 dataview

私有 sub btn_exit点击( byval sender as system。 object byval e as system.eventargs) handles button2.click
.close()
结束 sub
私有 sub kunciobjek()
txt_confirm。 readonly = true
txt_new。 readonly = true
txt_old。 readonly = true
结束 sub
私有 sub bukaobjek ()
txt_confirm。 readonly = false
txt_new。 readonly = false
txt_old。 readonly = false
结束 sub

私有 sub frm_chpass_load( byval sender as system。 object byval e as system.eventargs)句柄 mybase .load
dim cons as string =(" data source = tonny \ sqlexpress; initial catalog = app; persist security info = true; uid = sa; password = sally"
conn = sqlconnection(cons)
conn.open()
da = sqldataadapter(" select * from tbl_user",cons)
dim cb as sqlcommandbuilder(da)
da.fill(dt)
kunciobjek()
结束 sub


私有 sub btn_save_click( byval sender as system。 object byval e as system.eventargs)句柄 button1.click
me .bindingcontext(dt)。endcurrentedit()
da.update(dt)



结束 sub

私有 sub btn_changepasword( byval sender as system。 object byval e as system.eventargs)句柄 button3.click
bukaobjek()

结束 sub
结束






任何人都可以帮助我plz t__t我仍然是新手所以需要你的帮助..我不知道在button1做什么(按钮改变密码)

解决方案

你好朋友..



你可以用双向方式做到这一点..



1)全部使用用vb.net完成的代码

2)使用商店程序





1)使用完成的所有代码在vb.net中

注意:

"以下所有代码都是在asp.net中使用vb.net完成的,你需要根据你的要求进行更改"



  imports  system.data.sqlclient 
imports system.data

公共 _default
继承 system.web.ui.page
d im sqlcon 作为 sqlconnection
dim sqlda as sqldataadapter
dim dt as datatable
受保护的 sub page_load( byval sender 作为 对象 byval e 作为 system.eventargs)句柄 .load
如果 ispostback)那么
sqlcon = sqlconnection(" 你的连接字符串在这里"
结束 如果
结束 sub

受保护的 sub btnchangepass_click( byval sender as object byval e as eventargs)句柄 btnchangepass.click
dim username as string
dim oldpass as string = txtoldpass.text
dim newpass as 字符串 = txt newpass.text
如果(oldpass.equals(newpass))那么

username = " 您的用户名在这里"
dt = datatable()
sqlcon.open()
sqlda.selectcommand = sqlcommand(" select * from usertable where username = @username and pass = @pass",sqlcon)
sqlda .selectcommand.parameters.addwithvalue(" @ username",username)
sqlda.selectcommand。 parameters.addwithvalue(" @ username",oldpass)
dt.clear()
sqlda.fill(dt)
如果(dt.rows.countgt; 0 然后
dim userid 作为 字符串 = dt.rows( 0 )(" 你的id列")。tostring()
sqlda.updatecommand = sqlcommand(" update usertable set pass = @newpass where userid = @userid",sqlcon)
sqlda.updatecommand.parameters.addwithvalue(" @ newpass ",newpass)
sqlda.updatecommand.parameters.addwithvalue(" @ userid",userid)
sqlda.updatecommand.executenonquery()
结束 如果
其他
' 显示您的密码与用户的消息不匹配
结束 如果

结束 sub
结束






2)使用商店程序





  create   procedure  sp_change_pass 
- 在此处添加存储过程的参数
@ username nvarchar 20 ),
@ oldpass nvarchar 20 ),
@ newpass nvarchar 20 ),
@ resultid int = null
as
begin
- 添加set nocount on以防止额外的结果集
- 干扰select语句。
set nocount on ;

- 在此处插入程序语句
select @ resultid = id from testtable where 名称= @ username and pass = @ oldpass
if @ resultid is not null
begin
更新 testtable set pass = @ newpass where id = @ resultid
end
end
go




对于这个sp的使用,你需要传递三个参数,比如用户名,oldpass和新传递,

只调用那个sp,它将完成你改变的所有工作密码。

您还可以添加输出参数作为此sp的结果,供您在vb.net的代码页中使用

标签:需要帮助匡助更改密码表格



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

CMap或CMapPtrToPtr(CMap or CMapPtrToPtr)

problem hi, i want store the objects in cmap ...

如何创建新的任务栏(how to create new task bar)

problem hi, i want to create new taskbar,can any one hel ...

在C#.net中旋转PDF文件(Rotate PDF File in C#.net)

problem hi , how to rotate pdf file in c#.net ...

在C#.Net中旋转图像文件(Rotate Image Files in C#.Net)

problem hi, how to rotate image files(jpeg,ti ...

如何交换字符串中的字符(how to swap characters in a string)

problem hi all. i''m new in .net and i want t ...

如何在SHAREPOINT 2010中集成twitter(How to integrate twitter in SHAREPOINT 2010)

problem hi to all, this is siddiqali working ...

检查应用程序是否正在运行(Check If Application Is Running)

problem is there a way to run a loop that wou ...

如何使用radiobuttonlist?(how to use radiobuttonlist)

problem i want to write select query for selectedindexcha ...

如何计算日期差异和数字差异(How to Calculate Date Diff And Num Diff)

problem glnotranscationdate deposit withdraw transid loan ...

ie6浏览器问题在我的网页上(ie6 browser issue in my web page)

problem my webpage displaying 1 inleft bottom corner only ...

无法在表单上使用控件。(Unable to use controls on the form.)

problem hi, i have created some static insta ...

如何在Javascript中使用正则表达式匹配定义的模式(How to match defined pattern using regular expression in Javascript)

problem hi, first, there is a string called: var bookpat ...

我想打印收据,但我遇到了问题(I want to print a reciept but i face a problem)

problem in this project i am using datareport ...

Visual Studio 2010 + Windows 7 + 64位计算机+ C ++ + 32位DLLS = 3个问题(Visual Studio 2010 + Windows 7 + 64-bit computer + C++ + 32 bit DLLS = 3 problems)

problem i''ve been using visual studio 2005 for many year ...

什么是Eclipse以及如何使用它?(What is about Eclipse and how to use it)

problem how to use it .and for what purpose it is used so ...

如何从数据库中检索数据?(how to retrieve data from database)

problem i have a radiobuttonlist control and i want to re ...

使用SQL Management Studio将数据插入我的数据库时执行NonQuery(ExecuteNonQuery while inserting the data into my database using SQL Management Studio)

problem hi i have a problem while inserting the data int ...

我如何将C#.Net中的拖放图像转换为ASP.Net(how do i convert Drag and drop image in C#.Net to ASP.Net)

problem hi, i saw the drag and drop image in c#.net arti ...

如何禁用浏览器的后退按钮(How to disable browser's back button)

problem hello friend, i am using asp.net framework 3.5,i ...

滚动后无法打印文本....(Unable to print text after scrolling....)

problem hi, i have written a small c program ...