Search code examples
sqlvb.netsql-updateoledb

SQL syntax error in Update statement VB.net


I'm getting a strange syntax error when I run this in VB:

        SQLString = "UPDATE Login SET Password = '" + PasswordTextBox.Text + "'"
        SQLString += " WHERE UserName = '" + UserNameTextBox.Text + "'"

The Username is checked before getting to this part and is definitly in the database. It gives an exception saying that there's a syntax error in update statement. Anyone have any idea what's wrong?


Solution

  • Password is a reserved word so [Password] fixes it, my lecturer fixed to for me :)