Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dealing with SQL Server and apostrophies in strings
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00366868
Message ID:
00366909
Vues:
14
>Hi all.
>
>I dunno if this has been addressed anywhere, (I'm sure it probably has, but I haven't been able to find it...)
>
>When I started with my first FoxPro project last year, I ran into the problem of SQL Server not liking strings with apostrophies. I didn't know how to deal with it, so I told the users of my application just not to use apostrophies anywhere (there are only about 10 of them ;-)
>
>Well, this was all fine and dandy, (they didn't complain about it too much), until I started my next project. It involved a web-interfase to my SQL Server database, to which my original FoxPro application is linked.
>
>Needless to say, I can't ask users on the web *not* to use apostrophies, so I had to come up with a solution on both ends, because if web users are inserting apostrophies, the FoxPro application users are going to have to be able to read them...
>

This is a job for CHRTRAN() or STRTRAN() - simply transform the strings substituting something else, or adding the extra ' to each occurance of an ' on the way out to SQL Server, and translating the string back on the way down from SQL Server. Out to SQL Server:

REPLACE cFld WITH STRTRAN(cFld,"'","''")

Coming back:

REPLACE cFld WITH STRTRAN(cFld,"''","'")
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform