Click to See Complete Forum and Search --> : SQL syntax error that I don't get!


NatuScape
03-15-2005, 03:45 PM
Hi all,

I'm using the following code to insert a record into a table, but I keep getting the following error: "Microsoft JET Database Engine error '80040e14' Syntax error in INSERT INTO statement"

Here's the code:

conn1.Execute "INSERT INTO Scores (Site, Year, Quarter, Element, SubElement, Score) VALUES ('" & Request.Form("SiteToReport") & "'," & Request.Form("YearToReport") & "," & Request.Form("QuarterToReport") & ",'Hazard Assessments','Subelement 1: Hazard Assessments'," & Request.Form("HazardAssessments") & ")"

I've opened "conn1" as an ADODB connection as I've done a million times before, so I know that's not the problem. The query renders itself perfectly, here's what it renders:

INSERT INTO Scores (Site, Year, Quarter, Element, SubElement, Score) VALUES ('Bedford - Ashby Rd',2004,4,'Hazard Assessments','Subelement 1: Hazard Assessments',1)

As far as I can tell everything should be good to go into the table, but it doesn't.

What am I missing???? Thanks in advance!

Natalia :)

phpnovice
03-15-2005, 04:12 PM
Specify Year as [Year] to differentiate it from the SQL function by the same name -- unless that was your intent. In which case, specify Year more like Year(Now).

NatuScape
03-16-2005, 08:20 AM
Thank you so much!!!! I suspected it might be that I was tripping over some system-reserved name, but I couldn't figure out which.

Thanks again!

Natalia

phpnovice
03-16-2005, 08:30 AM
Cheers.