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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql syntax error

Status
Not open for further replies.

elpz

Programmer
Dec 18, 2000
1
DK
I keep getting syntax error using the following statement. Can anybody tell where exactly is my problem? The values for year, issue, pagenr, horizpos, vertpos, imgbord are numerical values. id is an autonumber in my access database so I assume it is also considered a numerical value for the purpose of SQL statements. The statement is modified from the second listed statement which works fine.

Set objRecordSet = objDataCon.Execute("UPDATE messages SET year = " & year & "," & "issue = " & issue & "," & "pagenr = " & pagenr & "," & "conttype = '" & conttype & "'," & "horizpos = " & horizpos & "," & "vertpos = " & vertpos & "," & "imgbord = " & imgbord & "," & "desc = '" & desc & "'," & "content = '" & page & "' " & "WHERE id = " & id, lRecordsFound)


Set objRecordSet = objDataCon.Execute("UPDATE messages SET ndate = " & dateformat(ndate) & ", title = '" & title & "', message = '" & page & "', file = '" & filename & "' WHERE id = " & id, lRecordsFound)
 
Try this:

Set objRecordSet = objDataCon.Execute("UPDATE messages SET year = " & year & ", issue = " & issue & ", pagenr = " & pagenr & ", conttype = '" & conttype & "', horizpos = " & horizpos & ", vertpos = " & vertpos & ", imgbord = " & imgbord & ", desc = '" & desc & "', content = '" & page & "' WHERE id = " & id, lRecordsFound)

Failing that, check that the text values in the variables conttype, desc and page do not contain any single quotes.

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top