Link to home
Start Free TrialLog in
Avatar of TOMMYC
TOMMYC

asked on

Updating a table using SQL

I'm trying to update a table using the following code and keep getting an error 3144 syntax error in the update statement.  If I take the where clause out it updates all the passwords in the table.


 
SQL = "UPDATE SECURITYABS SET " _
    & "PASSWORD = '" & UCase(txtNewPW.Text) & "', " _
    & "WHERE USERNAME = '" & UCase(txtUserName.Text) & "'"

Any help would be appreciated.

Thanks.




ASKER CERTIFIED SOLUTION
Avatar of samopal
samopal

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tkuppinen
tkuppinen

Take the the comma out

SQL = "UPDATE SECURITYABS SET " _
    & "PASSWORD = '" & UCase(txtNewPW.Text) & "'" & _
    & " WHERE USERNAME = '" & UCase(txtUserName.Text) & "'"

You may also want to look at using the replace function anytime you are inserting text into your db.  If there is a single quote in this string it will mess everything up.

pseudocode

Replace(textusername.text, " ' " , " '' ")

Of course you would have to take the spaces out, I just put them in to try to illustrate it more clearly.