CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2013
    Posts
    34

    [RESOLVED] Change Password Error

    Hello Sir,

    I am Create login form then change password form.. Heres my code
    i dont get it what is the problem of my code, VB 6 Say: Syntax Error Upadate Statement
    Code:
    Private Sub cmdOk_Click()
    Dim rs As New ADODB.Recordset
    Dim change As String
    
    
    
    If txtOld.Text = Login.txtPassword.Text Then
    rs.Open "Select Password From tblUser where UserID = '" & MDIForm1.id.Caption & "'", acd, adOpenForwardOnly
    
    change = "UPDATE tblUser SET Password ='" & txtNew.Text & "' where UserID = '" & MDIForm1.id.Caption & "'"
    acd.Execute change
    
    MsgBox "Change"
    Else
    MsgBox "Invalid Old Password"
          
    
    End If
    
    End Sub
    Help me sir thanks

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Change Password Error

    The only thing that jumps out at me in that line is that you are using Password as a field name which is something you should not be doing, Password is a reserved word. You should as a general rule avoid using any reserved words, spaces or special characters in field names. Of course sometimes the design of the tables is out of our control in which cases you need to use the trusty little [ ] trick

    Code:
    change = "UPDATE tblUser SET [Password] ='" & txtNew.Text & "' where UserID = '" & MDIForm1.id.Caption & "'"
    Is there a reason that you are using a select statement before the update there? I can't see any reason why you would do this in that piece of code. You are not doing anythign with it and then you are changing it 2 lines later so whatever is in that recordset would not be what is now in the database...
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Feb 2013
    Posts
    34

    Re: Change Password Error

    Thanks.. Run Perfectly.. ^_^

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured