| | |
ASP Replace Function....
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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.
ASP Syntax (Toggle Plain Text)
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:
ASP Syntax (Toggle Plain Text)
select * from customers where name = ' Lori '
Which is a perfectly legit SQL statement. BUT if you had something like this:
ASP Syntax (Toggle Plain Text)
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:
ASP Syntax (Toggle Plain Text)
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:
ASP Syntax (Toggle Plain Text)
select * from customers where name = ' O''Neil '
And that's why that replace function replaces single apostrophes with doubles.
![]() |
Similar Threads
- Replace Function (C#)
- Replace Function, Please Help!!!!! (Visual Basic 4 / 5 / 6)
- Help with find/replace function (C++)
- I want to send Asp value to Javascript function (VB.NET)
- ASP Date Function (ASP)
Other Threads in the ASP Forum
- Previous Thread: "ADODB Recordset error"
- Next Thread: force Search Page to return no records on open
| Thread Tools | Search this Thread |
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection connection database databaseconnection dreamweaver excel fso iis msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption single specfic sqlserver sqlserverconnection windows7






