Public rs As New ADODB.Recordset
Public conn As New ADODB.Connection
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "用戶名稱不能為空"
Text1.SetFocus
Exit Sub
End If
If rs.State <> adStateClosed Then rs.Close
rs.Open "Select * from bb where Name='" & Text1.Text & "'", conn, 3, 3
If rs.RecordCount = 0 Then
MsgBox "沒有此用戶名稱"
Text1.Text = ""
Text1.SetFocus
Exit Sub
End If
If rs.State <> adStateClosed Then rs.Close
rs.Open "Select * from bb where password='" & Text2.Text & "'", conn, 3, 3
If rs.RecordCount = 0 Then
MsgBox "你的密碼和原來的密碼不對,請重新輸入 !"
Text2.Text = ""
Text2.SetFocus
Exit Sub
End If
If Text3.Text <> Text4.Text Then
MsgBox "新的密碼兩次輸入不一置,請重新進行設置!"
Text3.Text = ""
Text4.Text = ""
Text3.SetFocus
Exit Sub
End If
conn.Execute "Update bb set [Password]='" & Text3.Text & "' where name='" & Text1.Text & "'"
MsgBox "密碼修改成功"
Unload Me
End Sub
Private Sub Form_Load()
Dim strconn As String
strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\aa.mdb;Persist Security Info=False"
conn.CursorLocation = adUseClient
conn.Open strconn
End Sub
Private Sub Form_Unload(Cancel As Integer)
If rs.State <> 0 Then rs.Close
Set rs = Nothing
Set conn = Nothing
Set Form1 = Nothing
private sub cmdeditpwd()
dim strsql as string
if trim(text3.text)<>trim(text4.text) then
msgbox "两次新密码输入不一致,请重新输入!",48,"提示"
exit sub
end if
strsql=" select 卡号,密码 from bb where 卡号='"& trim(text1.text) &"'"
if myrs.staste=adstateopen then myrs.close
myrs.open strsql,cnn,adopenkeyset,adlockreadonly
if myrs.recordcount=0 then
msgbox "输入的用户名不存在,请重新输入!",48,"提示"
myrs.close
exit sub
else
if not (isnull(myrs!密码) or myrs!密码="") then
if myrs!密码<>trim(text2.text) then
msgbox "输入的密码不正确,请重新输入!",48,"提示"
exit sub
myrs.close
end if
else
if trim(text2.text)<>"" then '表中没密码而登录时输入了密码
msgbox "输入的密码不正确,请重新输入!",48,"提示"
myrs.close
exit sub
end if
end if
'修改新密码
strsql=" update bb set 密码='"& trim(text3.text) &"' where 卡号='"& myrs!卡号 &"'"
cnn.execute strsql
msgbox "密码修改成功!",vbinformation,"提示"
end if
end sub