Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Option Explicit
Public conn As New ADODB.connection
Public rs As New ADODB.Recordset
Public rsinsert As New ADODB.Recordset

Sub connection()
Set conn = New ADODB.connection
conn.CursorLocation = adUseClient
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\ digitalsignage.mdb;Persist Security Info=False"
End Sub

Private Sub cmdPwdChanged_Click()
    If txtpass.Text = "" Then
        MsgBox "Old pasword is empty", vbCritical, Me.Caption
        Exit Sub
    End If
    If txtpassword.Text = "" Then
        MsgBox "New pasword is empty", vbCritical, Me.Caption
        txtpassword.SetFocus
        Exit Sub
    End If
    If txtchangepassword.Text = "" Then
        MsgBox "New confirm pasword is empty", vbCritical, Me.Caption
        txtchangepassword.SetFocus
        Exit Sub
    End If
    If txtpassword.Text <> txtchangepassword.Text Then
        MsgBox "New Password and Confirm password mismatch", vbCritical, Me.Caption
        txtchangepassword.SetFocus
        Exit Sub
    End If
 Set rs = conn.Execute("select * from users where Username= '" & txtuser.Text & "' and Password='" & txtpass.Text & "'")
    If rs.EOF Then
        MsgBox "Invalid old password, Password not in database", vbCritical, Me.Caption
        Exit Sub
    End If
    conn.Execute "Update users SET Password='" & txtpassword.Text = "' WHERE Username='" & txtuser.Text = "'"
     MsgBox "Password changed successfully", vbInformation, Me.Caption
     txtpass.Text = ""
     txtpassword.Text = ""
     txtchangepassword.Text = ""
End Sub


Private Sub Form_Load()
Call connection
End Sub

Private Sub cmdCancel_Click()
form2.Hide
form1.Show
End Sub


IT shows that syntax error in update stmt. plz help me.

[edit]Code blocks added - OriginalGriff[/edit]
Posted
Updated 25-Feb-12 21:30pm
Comments
Member 8678129 26-Feb-12 3:28am    
plz solve tha above error

1 solution

Yes, I'm not surprised:
SQL
conn.Execute "Update users SET Password='" & txtpassword.Text = "' WHERE Username='" & txtuser.Text = "'"
                                                              ^
                                                              |
Pretty sure that should be a '&' character...

BTW: Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900