Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error in sql 1

Status
Not open for further replies.

ParyGoal

MIS
Jul 22, 2006
70
US
Hello everyone
I am getting a syntax error in the sql statment while updating the database. I can't seem to find an error.
Below is the update statement I am using

TmpString = ""
TmpString = "UPDATE tblUserGroups "
TmpString = TmpString & " SET FirstName = '" & Apostrophe(ProperCase(Trim$(TextBox(0).Text))) & "', "
TmpString = TmpString & "LastName = '" & Apostrophe(ProperCase(Trim$(TextBox(1).Text))) & "', "
TmpString = TmpString & "UserFullName = '" & Apostrophe(ProperCase(Trim$(TextBox(2).Text))) & "', "
TmpString = TmpString & "MidInit = '" & Apostrophe(Trim$(TextBox(3).Text)) & "', "
TmpString = TmpString & "strUserName = '" & Apostrophe(Trim$(TextBox(4).Text)) & "',"
TmpString = TmpString & "Password = '" & Apostrophe(Trim$(TextBox(5).Text)) & "', "
TmpString = TmpString & "Access_Level = '" & Apostrophe(ProperCase(Trim$(ComboBox(0).Text))) & "', "
TmpString = TmpString & "TitleID = " & lngTitle & ", "
TmpString = TmpString & "WHERE strUserName = '" & tmpUserName & "'"

Does anyone see a problem with this update statement?

Thank you

ParyGoal
 
It'll be easier for us to help you if you tell us...

1. What database are you using?
2. What is the exact wording of the error message
3. What the resulting TmpString looks like just prior to executing this.



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Hi George

Very good questions.


I am using an access database.

Error message

Microsoft ODBC Microsoft Access Driver Syntax error in Update Statment
Err # -2147217900

Resulting TmpString

UPDATE tblUserGroups SET FirstName = 'Sam', LastName = 'Samula', UserFullName = 'Sam Samula', MidInit = 'M', strUserName = 'Ssamula', Password = '22222', Access_Level = 'Administrator', TitleID = 18, WHERE strUserName = 'Ssamula'

It looks like it's adding a comma before the where clause ,which is not allowed.

 
So... you found it yourself. Congratulations.

Code:
TmpString = TmpString & "TitleID = " & lngTitle & "[!],[/!] "

Just remove that comma (highlighted in red).

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Thank you George very much for your help.
It did the trick.

Tarik

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top