i need help on how to add NewPassword to the database and delete OldPassword
Code:
Option Explicit
Dim cmdCommand As New ADODB.Command
Dim myrecordset As ADODB.Recordset
Dim myConnection As ADODB.Connection
Private Sub Cancel_Click()
Load Administrator
Administrator.Show
Me.Hide
End Sub
Private Sub Command1_Click()
Set myConnection = New ADODB.Connection
Set myrecordset = New ADODB.Recordset
myConnection.ConnectionString = ConnString()
myConnection.Open
myrecordset.ActiveConnection = myConnection
myrecordset.Open "Select *from Passwords"
Dim newpass As String
Dim unamee As String
Dim hiyo As String
hiyo = myrecordset!Oldpassword
unamee = Oldpassword.Text
While myrecordset.EOF = False
If unamee = myrecordset!Oldpassword Then
myrecordset.MoveNext
MsgBox "ikoooooo"
newpass = changepassword(NewPassword.Text, ConfirmNew.Text)
If newpass = "-1" Then
Exit Sub
End If
GoTo continue
Else
If myrecordset.EOF = True Then
MsgBox "Old Password not found", vbCritical + vbOKOnly
Exit Sub
Else
myrecordset.MoveNext
End If
End If
'Else
'If unamee <> myrecordset!Oldpassword Then
'
' MsgBox "Password not found", vbInformation + vbOKOnly
' End If
' myrecordset.MoveNext
' End If
Wend
continue:
'With myrecordset
' .Delete
' .Fields(0) = "New"
' .Update
' End With
'myrecordset.AddNew
'With myrecordset
' .AddNew
' .Fields(0) = "New"
' .Update
' End With
' myrecordset.Close
'myrecordset.Fields("OldPassword").Value = "SomeValue"
'myrecordset.Update
End Sub
Private Function changepassword(ByVal newpass As String, ByVal confirm As String) As String
If newpass <> confirm Then
MsgBox "Passwords do not match", vbCritical + vbOKOnly
changepassword = "-1"
Else
changepassword = newpass
End If
End Function
Comment