Single Quote (Apostrophe) in Embedded Query? 
Author Message
 Single Quote (Apostrophe) in Embedded Query?

The following code fragment puts together an SQL statement and a
variable....

SQLstr = SQLstr & " AND name_last='" & name_last & "'"

This causes a problem in ASP when the person's last name happens to have
an apostrophe in it, for example, O'Donnell.

Can ASP be passed this variable using some other means so that the
quotation is not confused?

Craig



Sat, 27 Jul 2002 03:00:00 GMT  
 Single Quote (Apostrophe) in Embedded Query?
http://www.aspfaq.com/faq/faqShow.asp?fid=4


Sat, 27 Jul 2002 03:00:00 GMT  
 Single Quote (Apostrophe) in Embedded Query?
You may replace the single quote (') by two single quote ('') in your
string.
Lets try this ...

name_last=replace(name_last,"''","'")

SQLstr = SQLstr & " AND name_last='" & name_last & "'"

Ask me if there is any pb with this methode ...



Quote:
> The following code fragment puts together an SQL statement and a
> variable....

> SQLstr = SQLstr & " AND name_last='" & name_last & "'"

> This causes a problem in ASP when the person's last name happens to have
> an apostrophe in it, for example, O'Donnell.

> Can ASP be passed this variable using some other means so that the
> quotation is not confused?

> Craig



Sat, 27 Jul 2002 03:00:00 GMT  
 Single Quote (Apostrophe) in Embedded Query?
Craig.
Read this article - it will answer your question.

Please have a look at http://www.15seconds.com/
the article is at http://www.15seconds.com/issue/000204.htm

Boaz Sigelman

Quote:

> The following code fragment puts together an SQL statement and a
> variable....

> SQLstr = SQLstr & " AND name_last='" & name_last & "'"

> This causes a problem in ASP when the person's last name happens to have
> an apostrophe in it, for example, O'Donnell.

> Can ASP be passed this variable using some other means so that the
> quotation is not confused?

> Craig



Sat, 27 Jul 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Single Quotes converted to double Single Quotes

2. embedded single quotes

3. Need to embed single quote in SQL string

4. How to embed both single and double quotes in strings

5. Help!!!: Tables With Embedded Single Quotes

6. Embedded single quote

7. Using single ' (apostrophe) in a SQL query

8. single quotes in SQL Query Strings

9. Single quote's in Query (MsSQL + VB4)

10. Dealing with single quotes when building an SQL query

11. Single Quote - ' - in SQL query

12. Dealing with single quotes when building an SQL query

 

 
Powered by phpBB® Forum Software