How to change user passwords

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kazzaehh
    New Member
    • Dec 2009
    • 1

    How to change user passwords

    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
    Last edited by debasisdas; Dec 4 '09, 05:25 AM. Reason: Formatted using code tags
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    How can you change password without user name.

    steps to follow
    1. find the password from database using user name.
    2. compare with user input.
    3. if correct update the existing one with new password
    else re-prompt for old password.

    Comment

    Working...