|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Insert Into Syntax Error
I read through your posts and also other forum about this error and I did what was said but I still get this error:
INSERT INTO feedback ([pname], [email], [comments], [outcome], [additional], [try]) VALUES ( Microsoft JET Database Engine error '80040e14' Syntax error in INSERT INTO statement. /room20/survey.asp, line 33 I even put everything in brackets, just to be on the safe side for reserved words.I did not do Word Wrap, so everything is on one line. Complete code is as follows: <% dim pname dim email dim comments dim outcome dim additional dim answer dim oConn dim sConnection dim sql pname=Request.Form("name") email=Request.Form("email") comments=Request.Form("comments") outcome=Request.Form("outcome") additional=Request.Form("additional") answer=Request.Form("try") Set oConn = Server.CreateObject("ADODB.Connection") sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & Server.MapPath("\room20\db\survey.mdb") & ";" & _ "Persist Security Info=False" oConn.Open(sConnection) sql="INSERT INTO feedback ([pname], [email], [comments], [outcome], [additional], [try]) VALUES ("' & pname & '", "' & email & '", "' & comments & '", "' & outcome & '", "' & additional & '", "' & answer & '")" response.write(sql) oConn.Execute sql if err<>0 then Response.Write("<b>Sorry, due to technical difficulties your feedback has not been submitted.</b>") else Response.Write("<h4>Your feedback has been submitted. Thank you!</h4>") end if oConn.Close %> What might be wrong? Thanks. |
|
#2
|
|||
|
|||
|
step one would be to take it to the DB's command prompt and get it working that way? do you have access to the command prompt? Notice the error cuts of after VALUES (... that means that's all it's getting, so let's look at your asp code
Step 2 would be to use correct string concatenation you have (" ' & pname & ' ", you need to use (' " & pname & " ', the ' is what needs to appear in the sql statement. and the " are what close the string to put in variables. |
|
#3
|
|||
|
|||
|
Looks to me like you've got your tick marks and quote marks reversed.
should be insert ..... values (' " & somevariable & " ', ' " & somevariable & " ', ' " Yours looks to me like insert...values (" ' & somevariable & ' ", " ' & somevariable & ' ", ' "..... |
|
#4
|
|||
|
|||
|
ALSO...
---BEGIN QUOTE--- I even put everything in brackets, just to be on the safe side for reserved words ---END QUOTE--- You know, Microsoft doesn't create reserved words every months! So why "just to be on the safe side"? Here...bookmark this website, it holds *all* the reserved words for Access, SQL Server and others... http://www.aspfaq.com/show.asp?id=2080 It is *YOUR* job as a programmer to make sure NOT TO USE reserved words! It can/will occasionally happen but not to you, not anymore anyway, since you've bookmarked the website ![]() Hope this helps! Sincerely Vlince |
|
#5
|
|||
|
|||
|
What does your response.write show for your sql statement?
Often missing or illegal form data is the culprit. I think it's a good idea to "sanitize" any user input data before using it as part of a SQL string. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Insert Into Syntax Error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|