Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problems with Apostroph in variable!
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00209007
Message ID:
00209012
Views:
15
There are a couple of ways to deal with this. You could use [] instead of ' to delimit your string. The easier solution is probably to leave the ALLTRIM(THIS.Value) in your SELECT and use ? to tell VFP it's a parameter. This solution will also work if you're using SQLEXEC() to send your query to a remote data source. Try this:

cMyVar = "ALLTRIM(MyTable.MyField) = ?ALLTRIM(THIS.VALUE)"

>Hello,
>I'm using a variable in the WHERE clause of a SQL Statement. The variable looks like so:
>cMyVar = "ALLTRIM(MyTable.MyField) = '" + ALLTRIM(THIS.VALUE) + "'"
>
>Naturally, if MyTable.MyField contains an apostroph (like "De'Isle"), I get a syntax error :-(
>What do I have to do in this case?
>Thanks in advance for your help!
Previous
Reply
Map
View

Click here to load this message in the networking platform