VB 需修改密码模块代码
所做系统为VB和ACCESS,最简单的那种,可以修改密码就行,需要代码.我自己的代码貌似不能用,或者帮我修改下也行.我自己的代码是PrivateSubCommand1_C...
所做系统为VB和ACCESS,最简单的那种,可以修改密码就行,需要代码.我自己的代码貌似不能用,或者帮我修改下也行.
我自己的代码是
Private Sub Command1_Click()
Dim sql As String
Dim rs_chang As New ADODB.Recordset '声明rs_chang为对象类型的变量
Dim conn As New ADODB.Connection '声明conn 为对象类型的变量
conn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\facility.mdb" 'App.path指定.VBP工程文件的路径
If Trim(Text1.Text) <> Trim(Text2.Text) Then
MsgBox "密码不一致!", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Text1.Text = ""
Text2.Text = ""
Else
sql = "select * from 系统管理 where 用户名='" & userID & "'"
rs_chang.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_chang.Fields(1) = Text1.Text
rs_chang.Update
rs_chang.Close
MsgBox "密码修改成功", vbOKOnly + vbExclamation, ""
Unload Me
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
End Sub
谢谢拉! 展开
我自己的代码是
Private Sub Command1_Click()
Dim sql As String
Dim rs_chang As New ADODB.Recordset '声明rs_chang为对象类型的变量
Dim conn As New ADODB.Connection '声明conn 为对象类型的变量
conn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\facility.mdb" 'App.path指定.VBP工程文件的路径
If Trim(Text1.Text) <> Trim(Text2.Text) Then
MsgBox "密码不一致!", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Text1.Text = ""
Text2.Text = ""
Else
sql = "select * from 系统管理 where 用户名='" & userID & "'"
rs_chang.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_chang.Fields(1) = Text1.Text
rs_chang.Update
rs_chang.Close
MsgBox "密码修改成功", vbOKOnly + vbExclamation, ""
Unload Me
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
End Sub
谢谢拉! 展开
展开全部
例:窗口一个form1,按钮两个cmdok,cmdcancel,文本框三个txtold,txtnewm,txtcheck,数据库名testdb,用户表user,用户名字段u_name,口令字段u_pass
代码:
private sub cmdcancel_click()
unload me
end sub
private sub cmdok_click()
if txtold.text="" and txtnew.text="" and txtcheck.text="" then
msgbox "确保旧口令或校验口令不为空!"
exit sub
end if
if txtnew.text<>txtcheck.text then
msgbox "两次输入口令不一致!"
exit sub
end if
dim connstr as string
connstr="provider=microsoft.jet.oledb.4.0;data source=" & app.path & "\testdb.mdb"
dim conn as new adodb.connection
conn.open connstr
dim rs as new adodb.recordset
dim sql as string
sql="select * from user where u_name='" & 用户名 & "'"
rs.open sql,conn,3,3
if rs("user_pass")<>txtold.text then
msgbox "原口令错误!"
rs.close
conn.close
exit sub
enf if
with rs
!u_pass=txtcheck.text
.update
.close
end with
conn.close
msgbox "口令修改完成!'
end sub
代码:
private sub cmdcancel_click()
unload me
end sub
private sub cmdok_click()
if txtold.text="" and txtnew.text="" and txtcheck.text="" then
msgbox "确保旧口令或校验口令不为空!"
exit sub
end if
if txtnew.text<>txtcheck.text then
msgbox "两次输入口令不一致!"
exit sub
end if
dim connstr as string
connstr="provider=microsoft.jet.oledb.4.0;data source=" & app.path & "\testdb.mdb"
dim conn as new adodb.connection
conn.open connstr
dim rs as new adodb.recordset
dim sql as string
sql="select * from user where u_name='" & 用户名 & "'"
rs.open sql,conn,3,3
if rs("user_pass")<>txtold.text then
msgbox "原口令错误!"
rs.close
conn.close
exit sub
enf if
with rs
!u_pass=txtcheck.text
.update
.close
end with
conn.close
msgbox "口令修改完成!'
end sub
展开全部
Dim cn As New ADODB.Connection
Dim sq As String
Private Sub Command1_Click()
cn.Open "provider=Microsoft.jet.OLEDB.4.0;data source=" & App.Path & "\Data.mdb"
sq1 = "update 用户表 set 密码='" & 新密码 & "' where 操作员='" & Form5.操作员 & "'"
cn.Execute (sq1)
MsgBox "您的新密码修改完成...", vbInformation, "修改密码"
cn.Close
Set cn = Nothing
End Sub
Dim sq As String
Private Sub Command1_Click()
cn.Open "provider=Microsoft.jet.OLEDB.4.0;data source=" & App.Path & "\Data.mdb"
sq1 = "update 用户表 set 密码='" & 新密码 & "' where 操作员='" & Form5.操作员 & "'"
cn.Execute (sq1)
MsgBox "您的新密码修改完成...", vbInformation, "修改密码"
cn.Close
Set cn = Nothing
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询