embedded quotes in data 
Author Message
 embedded quotes in data

i use a data1.recordset.findfirst "Name='" & NameToFind & "'"
the problem comes when the actual database record contains a quote.
ie.  Jim's Home

If I enter Jim's Home as the NameToFind, the findfirst becomes:
data1.recordset.findfirst "Name='Jims' Home'"
                                ^    ^     ^
with big toime problems with the now tripled single quotes.

I could strip the NameToFind leaving "Jims Home" but now the
findfirst would always fail because the data in the database
contains the single quote... Jims Home <> Jim's Home

Any advice other than cleaning all single quotes from the
database??



Sat, 07 Jul 2001 03:00:00 GMT  
 embedded quotes in data

Quote:

>i use a data1.recordset.findfirst "Name='" & NameToFind & "'"
>the problem comes when the actual database record contains a quote.
>ie.  Jim's Home

>If I enter Jim's Home as the NameToFind, the findfirst becomes:
>data1.recordset.findfirst "Name='Jims' Home'"
>                                ^    ^     ^
>with big toime problems with the now tripled single quotes.

>I could strip the NameToFind leaving "Jims Home" but now the
>findfirst would always fail because the data in the database
>contains the single quote... Jims Home <> Jim's Home

>Any advice other than cleaning all single quotes from the
>database??

You can do this (I ran into the same problem myself)

data1.recordset.findfirst "Name=" & chr$(34) & "Jim's Home" & chr$(34)

What this does is insert Quotationmarks into the string, these are double
quotes. This will work unless you have a name like: Jim "The Weasle" Martin
Because that contains DoubleQuotes, this will no longer work.



Sat, 07 Jul 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to handle data with embedded quotes

2. embedded single quotes

3. Wish List: Embedded Quotes in VB.Net

4. Embedding quotes in string var ?

5. Embedding Double Quotes in a String -- How?

6. Help embedding quotes in strings

7. Need to embed single quote in SQL string

8. How to embed double quote in a string?

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

10. Embedded quotes in HTML

11. ASP vbscript - embedded quotes syntax question

12. Single Quote (Apostrophe) in Embedded Query?

 

 
Powered by phpBB® Forum Software