Monday, February 27, 2012

Help me!!!

sSQL = "INSERT into order (Idea, [pass], [pass1], [brands], [models], [attention], [address], [town], [code], [county], [country], [dp1], [p2], [fx], [email]) values ('" & i & "', '" & pass & "', '" & pass1 & "', '" &_
brands & "', '" & models & "', '" & attention & ", '" & address & "', '" & town & "', '" & code & "', '" & county & "', '" & country & "', '" & dp1 & "', '" & p2 & ", '" & fx & ",'" & email & "')"
'define the connection string, specify database
'driver and the location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source= C:\Inetpub\wwwroot\worldcar\car.mdb "
'create an ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")
connection.Mode = 0
'Open the connection to the database
connection.Open(sConnString)
connection.execute(sSQL)<<<<line44

response.redirect ("E:\car1\welcome.htm")
'Done. Close the connection object
connection.Close

this is my asp coding and i keep on getting this problem

Syntax error in INSERT INTO statement.
/worldcar/add_to_database1.asp, line 44

It looks like the code pasted above is missing snigle-quotes at a few places:

...

& attention & ", '"

...

& p2 & ", '"

& fx & ",'"

If firther troubleshooting is needed, I suggest you print the sSQL string before the failing line to examine the string for correctness.

As a side-note, I would recommend looking into parameters instead of string concatenation to avoid exposure to SQL-injection.

No comments:

Post a Comment