-
SQL/ASP error
Some of my fields are names with ' in them (ex: Kelly's Pub, Tom's Place). When I try to do do a query for these names in ASP, the ' in the string causes an error.
Quick example:
var = "Kelly's Pub"
rsRecordSet.Open "SELECT * FROM Ads WHERE Rest = ' " & var & " ';"
What I end up getting is three ' which doesn't work. Can I replace the two outside ' with another symbol? What is the best way to work around my problem?
-
Use the replace statement. When you save it to the database. Then you can use SQL to retrieve it.
PHP Code:
strings = Replace(Exp,"'","''")
THat is Replace(Exp,','') Double single quoates " ' ".
-
You do not have to modify your data to solve the problem, just modify your sql statement.
Replace the single quotes in the sql string by 2 double quotes like this:
rsRecordSet.Open "SELECT * FROM Ads WHERE Rest = "" " & var & " "";"
Your DB will do the translation and wont give any errors on the use of quotes in your variables.
Greetz, Luc
-
Thanks for the answers. I will try them out.