•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 427,119 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,089 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 47893 | Replies: 1
![]() |
•
•
Join Date: Feb 2002
Location: Long Island, NY
Posts: 1,134
Reputation:
Rep Power: 12
Solved Threads: 4
That's to escape apostrophe signs usually in query strings. If you have a query string, let's say something like this:
There won't be a problem. The sql statement, after it's been merged with the variable name will look like this:
Which is a perfectly legit SQL statement. BUT if you had something like this:
It would crap out because of that apostrophe sign in O'Neil. So the SQL statement will look like this:
Which the database will think the apostrophe after the O is the end of the SQL statement and will wonder about the trailing "Neil" - how do you fix this? You escape the apostrophe sign by double it. So it would look like this:
And that's why that replace function replaces single apostrophes with doubles.
name = "Lori" sql = "select * from customers where name = ' " & name & " ' "
There won't be a problem. The sql statement, after it's been merged with the variable name will look like this:
select * from customers where name = ' Lori '
Which is a perfectly legit SQL statement. BUT if you had something like this:
name = "O'Neil" sql = "select * from customers where name = ' " & name & " ' "
It would crap out because of that apostrophe sign in O'Neil. So the SQL statement will look like this:
select * from customers where name = ' O'Neil '
Which the database will think the apostrophe after the O is the end of the SQL statement and will wonder about the trailing "Neil" - how do you fix this? You escape the apostrophe sign by double it. So it would look like this:
select * from customers where name = ' O''Neil '
And that's why that replace function replaces single apostrophes with doubles.
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- ASP Date Function (ASP)
- do u advice me to do my online store using ASP or PHP (IT Technologies and Trends)
- Pointer to function as an argument (C++)
- " ' " and post method : use of replace function ? (ASP)
- ASP, Java and XML-RPC (ASP)
- Jscript Replace Function (ASP)
Other Threads in the ASP Forum
- Previous Thread: "ADODB Recordset error"
- Next Thread: force Search Page to return no records on open



Linear Mode