|
-
Aug 27th, 2001, 06:45 PM
#1
Thread Starter
Hyperactive Member
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?
-
Aug 28th, 2001, 02:40 AM
#2
Lively Member
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 " ' ".
-
Aug 28th, 2001, 03:49 AM
#3
Hyperactive Member
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
-
Aug 28th, 2001, 09:17 AM
#4
Thread Starter
Hyperactive Member
Thanks for the answers. I will try them out.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|