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

Single quote(') cause SQL statement problem in text input form.

Status
Not open for further replies.

royyan

Programmer
Jul 18, 2001
148
US
I am trying to create a form to update news. The form I created are working. The only problem is if I try to put a block of text which include a single quote into the form, there will be a SQL statement error. Any expert can tell me how I can deal with this issue.
I am using Microsoft access as database. Thanks!
 
dim theValue
theValue = request.form("theValue")
theValue = replace(theValue,"'","''")

So that any single ticks are replaced w/ two single ticks. Should clear it right up for you.

:)
paul
penny.gif
penny.gif
 
If I remember correctly you must use 2 quotes.
example. "INSERT INTO table (row1) VALUES ('It''s cold today')
 
use:

Replace(Request.Form("field"), "'", "''")

replaces the single 's with double ''s

to further clean up your input data, can even add Trim:

Trim(Replace(Request.Form("field"), "'", "''"))

which will remove any leading spaces.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top