Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL - Update Statment with quotes
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00266878
Message ID:
00266936
Views:
19
You need to use the STRTRAN Function when using single quotes.. when using "'" you need to use '' to regard ' as a literal.

your command will look like this..

lcDiary = Allt(strtran(lcDiary,"'","''"))

Regards,
Fred
>>I have a program that creates an SQL pass through statment to update a memo field in an SQL table. Here's the code:
>>
>>lcDiary = "It's great to be alive"
>>l_cSQL ="UPDATE tmtrans SET diary = '"+ lcdiary+ "' WHERE id = 11 "
>>? sqlexec(1,l_csql)
>>
>>The return is a -1 and the error states Incorrect syntax near s. The problem is caused because there is a ' in the variable lcDiary.
>>
>>I tried to use double quotes in the l_cSql variable but that does not work. Furthermore, I may have cases were users key in both ' amd " quotes. I want to be able to change the delmiter in SQL server prior to executing my command to somethinhg like "{". I could then write a function to determine if the delimiter was in the text and set SQL correctly prior to updating the table. Can anyone help with changing the SQL server setting?
>>
>>Thanks in advance....
>
>Try using [] as another alternative for quotes.
Fred Besterwitch, MCP

The harder you work. The luckier you get.
Previous
Reply
Map
View

Click here to load this message in the networking platform