User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Nov 2003
Location: Philippines
Posts: 7
Reputation: vyruzxxx21 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
vyruzxxx21 vyruzxxx21 is offline Offline
Newbie Poster

Help ASP Replace Function....

  #1  
May 14th, 2004
Hi techies, I have searched so many "Replace" function topics, but there is something that I don't understand....I found some like this... Replace(strField, " ' ", " ' ' ") .... do anyone knows what's the use of replaceing ' with ' ' ? Tnx in advance.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2002
Location: Long Island, NY
Posts: 1,134
Reputation: samaru is just really nice samaru is just really nice samaru is just really nice samaru is just really nice 
Rep Power: 12
Solved Threads: 4
Colleague
samaru's Avatar
samaru samaru is offline Offline
a.k.a inscissor

Re: ASP Replace Function....

  #2  
May 24th, 2004
That's to escape apostrophe signs usually in query strings. If you have a query string, let's say something like this:

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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP Forum

All times are GMT -4. The time now is 6:17 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC