jstohler
asked on
Code cuts off input at apostrophe(')
When sending form data to my database, sometimes the input gets cut off if there's an apostrophe. E.g.: "Bob's House of Fun" makes it to the database only as "Bob". Is there an easy fix for this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I never used replace before, but it looks easy enough. Can I use a line like:
objRec("Sitename") = replace(Request.Form("requ iredSiteNa me")"'","' '")
or does it need to be an independent command?
objRec("Sitename") = replace(Request.Form("requ
or does it need to be an independent command?
Sure... that will work fine.
ASKER
Thanks! Great response time, too.
The above should be:
Simply use the VBScript replace command to replace every ' (single apostrophe) with a '' (double apostrophe). This will prevent termination of the code.
As in:
MySQLString = "Bob's House of Goats"
Replace MySQLString, "'", "''"
objRS.Open MySQLString
or
MySQLString = Replace(MySQLString, "'", "''")
objRS.Open MySQLString
Both with work.