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

Syntax error (missing operator) in query expression 1

Status
Not open for further replies.

Dashsa

Programmer
Aug 7, 2006
110
US
Hello I am collecting info from a form and trying to insert it into a Access Table.
I am getting the following error.
Code:
Syntax error (missing operator) in query expression ''Thu Jul 01 19:35:59 2010david's Test', '4')'.

I have printed the Sql and it is
Code:
 Insert INTO CustomEntry (EmailAddress, userPass, NameEntry, AddressEntry, CityEntry, StateEntry, ZipEntry, CostEntry, DateStarted, DateComplete, SquareFootage, ResidentLastName, Directions, GenralUID, Complete ) VALUES ('dash1@dash.com', '1', 'ww', 'ww', 'ww', 'ww', 'ww', 'ww', 'ww', 'ww', 'ww', 'ww', 'ww', 'Thu Jul 01 19:35:59 2010david's Test', '4')

the SQL code is
Code:
DIM objConn2
Set objConn2 = Server.CreateObject("ADODB.Connection")
objConn2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("/test.mdb") & ";"
objConn2.Open

sql=""
sql = sql & "Insert INTO CustomEntry "
sql = sql & "(EmailAddress, userPass,  NameEntry,  AddressEntry, CityEntry, StateEntry, "
sql = sql & "ZipEntry, CostEntry, DateStarted, DateComplete, SquareFootage, ResidentLastName, " 
sql = sql & "Directions, GenralUID, Complete ) "

sql = sql & "VALUES ('"& Session("Umail")& "', "
sql = sql & "'" & Session("upass") & "', "
sql = sql & "'" & eName & "', "
sql = sql & "'" & eAdd1 & "', "
sql = sql & "'" & eCity & "', "
sql = sql & "'" & eState & "', "
sql = sql & "'" & eZip & "', "
sql = sql & "'" & eCost & "', "
sql = sql & "'" & eStart &"', "
sql = sql & "'" & eComp & "', "
sql = sql & "'" & eSqu & "', "
sql = sql & "'" & eLstNme & "', "
sql = sql & "'" & eDirec & "', "
sql = sql & "'" & Session("uniqueD") & "', "
	sql = sql & "'" & formNumber & "')"
 

Response.Write(sql)
Set rs=objConn2.Execute(sql)

Any help would be greatly appreciated!!
Thanks
 
Code:
sql = sql & "'" & [!]Replace([/!]Session("uniqueD")[!], "'", "''")[/!] & "', "

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
WHoooo!
Thanks a BUNCH!
why do I need to replace that session var and not the two above it??

thanks again.
 
Actually I got it,
Thanks again....
Stupid 's
:)
 
In fact, for safety purpose, you should do the Replace for all var.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top