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

apostrophies in string throws errors 1

Status
Not open for further replies.

ryandoah

Programmer
Mar 5, 2004
101
US
Hi all,
I've got an asp query that I am running and can't remember how to cloak apostrophies in the string variable so that it doesn't break my VBScript before sending the query to SQL.

Code is something like this:
Code:
strSC = "SELECT dbID, dbName FROM dbTable WHERE dbName LIKE '%" & varName & "%';"

If varName has an/any apostrophies in it, it of course breaks the string, since ' is a string delimiter in VBScript. I've been told to go through and replace the apostrophy with a tilde(~) or something, but figured there was a more streamlined method where I wouldn't have to parse the string coming in and out of storage. Maybe parse it into the HTML ' equiv?

Thanks,
ryandoah
 
Have you tried this ?
LIKE '%" & Replace(varName,"'","''") & "%';"

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I thought about using that, since all I really doing is comparing the values, but didn't want to have to also parse the value coming out of the table. I could've sworn there was a way to simply mask the screen. But I tyr the replace in the mean time.
Thanks,
ryandoah
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top