在vb中怎么实现用户密码修改? 10
vb是与access数据库连接的。下面是我写的一点代码,但是实现不了,请帮我补充一下!PrivateSubCommand1_Click()IfText1.Text=""T...
vb是与access数据库连接的。
下面是我写的一点代码,但是实现不了,请帮我补充一下!
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "请输入用户名"
Text1.SetFocus
Exit Sub
End If
If Text2 <> Text3 Then
MsgBox "新密码和确认密码不相同,请重新确认"
Text3.SetFocus
Text3.SelStart = 0
Text3.SelLength = Len(Text3)
Exit Sub
End If
Unload Me
End Sub 展开
下面是我写的一点代码,但是实现不了,请帮我补充一下!
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "请输入用户名"
Text1.SetFocus
Exit Sub
End If
If Text2 <> Text3 Then
MsgBox "新密码和确认密码不相同,请重新确认"
Text3.SetFocus
Text3.SelStart = 0
Text3.SelLength = Len(Text3)
Exit Sub
End If
Unload Me
End Sub 展开
2个回答
展开全部
数据库连接正常了吗?
以下给个代码示例一下:
Public Conn As ADODB.Connection
'#--------------------------#
'# Access 数据库连接 #
'#--------------------------#
Public Sub ConnectDB(ByVal strDBFile As String)
Set Conn = New ADODB.Connection
Conn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBFile & ";"
End Sub
'#--------------------#
'# 修改密码 #
'#--------------------#
Function EditUser(ByVal FUser As String, ByVal FPwd As String) As Boolean
Dim tRs As New ADODB.Recordset
Dim sSql As String
On Error Resume Next
EditUser = False
sSql = "Select * From [User] Where [FUser]='" & FUser & "'"
tRs.Open sSql, Conn, 1, 2
If FPwd <> "" Then tRs("FPwd") = MD5(FPwd)
'密码先进行MD5加密后存入数据库
tRs.Update
tRs.Close
Set tRs = Nothing
If Err.Number = 0 Then EditUser = True
End Function
以下给个代码示例一下:
Public Conn As ADODB.Connection
'#--------------------------#
'# Access 数据库连接 #
'#--------------------------#
Public Sub ConnectDB(ByVal strDBFile As String)
Set Conn = New ADODB.Connection
Conn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBFile & ";"
End Sub
'#--------------------#
'# 修改密码 #
'#--------------------#
Function EditUser(ByVal FUser As String, ByVal FPwd As String) As Boolean
Dim tRs As New ADODB.Recordset
Dim sSql As String
On Error Resume Next
EditUser = False
sSql = "Select * From [User] Where [FUser]='" & FUser & "'"
tRs.Open sSql, Conn, 1, 2
If FPwd <> "" Then tRs("FPwd") = MD5(FPwd)
'密码先进行MD5加密后存入数据库
tRs.Update
tRs.Close
Set tRs = Nothing
If Err.Number = 0 Then EditUser = True
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询