seanpowell
asked on
Inserting an apostrophe causes error
Hi,
I'm getting this when someone uses an apostrophe in a memo field:
Microsoft JET Database Engine error '80040e14'
Syntax error (missing operator) in query expression
Below is the basic code I'm using:
Can anyone help?
I'm getting this when someone uses an apostrophe in a memo field:
Microsoft JET Database Engine error '80040e14'
Syntax error (missing operator) in query expression
Below is the basic code I'm using:
Can anyone help?
<%
Dim q1, q2, data_source, con, sql_insert
q1 = Request.Form("q1")
q2 = Request.Form("q2")
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("../db/cpc-survey.mdb")
sql_insert = "INSERT INTO results (q1, q2, [Timestamp]) VALUES ('" & q1 & "', '" & q2 & "', Now())"
Set con = Server.CreateObject("ADODB.Connection")
con.Open data_source
con.Execute sql_insert
con.Close
Set con = Nothing
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks - had a hard time figuring out how to incorporate that.
And lightening fast too :-)
And lightening fast too :-)
ASKER
Wonderful - thank you so much ;-)
<%
Dim q1, q2, data_source, con, sql_insert
q1 = Request.Form("q1")
q2 = Request.Form("q2")
data_source = "Provider=Microsoft.Jet.OL
sql_insert = "INSERT INTO results (q1, q2, [Timestamp]) VALUES ('" & Replace(q1, "'", "''") & "', '" & Replace(q2, "'", "''") & "', Now())"
Set con = Server.CreateObject("ADODB
con.Open data_source
con.Execute sql_insert
con.Close
Set con = Nothing
%>