Archived

This topic is now archived and is closed to further replies.

silvermace

MS Access SQL: Syntax Error in INSERT INTO Statement

Recommended Posts

im using ASP and a simple mdb, is there any way i can find out exacly what the error is? my sql query is rather long
Query = "INSERT INTO InformationRequests ( FirstName, LastName, CompanyName, Title, Addy1, Addy2, City, State, ZipCode, Country, Tele, Email, NumEmployees, HeardAboutUs, Re1, Re2, Re3, Re4, Re5, Re6, AdditionalQuestions, Date ) VALUES ( ''" & firstname & "'',''"&lastname&"'',''"&company&"'',''"&title&"'',''"&addy1&"'',''"&addy2&"'',''"&city&"'',''"&state&"'',''"&zipcode&"'',''"&country&"'',''"&tele&"'',''"&email&"'',''"&numemps&"'',''"&foundhow&"'',''"&re1&"'',''"&re2&"'',''"&re3&"'',''"&re4&"'',''"&re5&"'',''"&re6&"'',''"&questions&"'',''"&NowDate&"'' )"
 
anyone? A GOOD friend will come bail you out of jail... but, a TRUE friend will be sitting next to you saying, "Damn, we fucked up." Ingite 3D Game Engine Home -- Just click it

Share this post


Link to post
Share on other sites
The best way (that I have seen at least) is to have your page print out Query with a plain Response.Write and then copy and paste it exactly as it is into a blank query in access (via the Query Design - SQL View). Then just click the execute query button and it''ll tell you exactly what is wrong. My bet is that "Date" is a keyword (watch out for fields named "User" or "Password" too because they''ll get you too.) I would try [Date] instead of Date, so that access knows you are talking about the Date field in the table and not something else. Also, if the Date field is a Date/Time field type, then instead of ,''"&NowDate&"'' it would be ,#"&NowDate&"# (just use # instead of ''). If neither of those help, then you''ll just have to put it in access to see what the problem is (or give your DB to someone who can help you with it.)

-Adam

Share this post


Link to post
Share on other sites