VB修改不了密码
帮我看看 急Dim msg As String
Private Sub CmdCancel_Click()
Inventory_management.Enabled = True
Unload Me
End Sub
Private Sub Form_Load()
Dim rst As ADODB.Recordset
Dim strItem As String
SQL = "select UserID,Username From User_information Order by UserID"
Set rst = SelectSQL(SQL, msg)
If rst.RecordCount > 0 Then
Do While Not rst.EOF
strItem = rst.Fields(0) & " " & rst.Fields(1)
CboName.AddItem (strItem)
rst.MoveNext
Loop
rst.Close
CboName.ListIndex = 0
Else
MsgBox ("Please create user information")
CmdOK.Enabled = False
Exit Sub
End If
End Sub
Private Sub CmdOK_Click()
Dim rst As ADODB.Recordset
Dim password As String
Dim pOld As String
Dim pNew As String
Dim pCheck As String
pOld = Trim(TextOld.Text)
pNew = Trim(TextNew.Text)
pCheck = Trim(TextCheck.Text)
UserID = Left(Trim(CboName.Text), 4)
SQL = "Select UserID,Username,Password from User_information where UserID ='" & UserID & "'"
SQL = SQL & " AND Password='" & pOld & "'"
On Error GoTo ErrMsg
Set rst = SelectSQL(SQL, msg)
If rst.RecordCount > 0 Then
If (pCheck <> pNew) Then
MsgBox ("Enter a password twice inconsistency")
Exit Sub
End If
rst.Fields("Password") = pNew
rst.Update
MsgBox ("Update success")
Else
MsgBox ("Enter the old password error")
Exit Sub
End If
Exit Sub
ErrMsg:
MsgBox Err.Description, vbExclamation, "Error"
End Sub