Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Passthru
Message
 
To
09/11/2002 10:52:23
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, United States
General information
Forum:
Visual FoxPro
Category:
Client/server
Title:
Miscellaneous
Thread ID:
00719981
Message ID:
00721888
Views:
24
Thanks for this information. I did not know that the ODBC driver will handle single quotes as part of the string. However in this case since I saving large memo fields, the string concatination would have exceeded the size limit of a SQL statement (8000 characters?). Anyway, I found the problem was the ODBC driver to the Prototyped Fox Table seems unable to handle blank dates whereas the SQL version seems to automatically convert them to 1/1/1900. It was because some of the passed fiels had blank dates that the insert statement was failing.

Troy

>Troy
>
>I am getting into this thread late but I did not see the answerer here. You need to add another single quote to the exiting one. SQL Server will strip out the extra and it knows not to end the string. In my framework, I always run all variables through a function that adds a ' to any existing '.
>
>
>lcMyVar = strtran(lcMyVar,"'","''")
>
>
>>Thanks, I normally use that technique, but in this case some of the fields may contain single quotes within themselves and I can't strip them out because another application that uses this data relies on them. Also, some of the fields are memos and could be quite long.
>>
>>I also tried the technique of making a cursor updatable, but many of the fields do not update for some reason.
>>
>>>>>sqlexec(iCH, "insert into table (field1,field2) values (?oRec.field1, ?oRec.Field2)")
>>>
>>>You are sending a string to SQL Server that includes references to an object that exists only in your application. Try:
>>>
>>>
>>>cSql = "Insert into table(field1, fields2) values ("
>>>cSql = cSql + "'" + oRec.Field1 + "', "  && Field 1 contains a string, needs single quotes
>>>cSql = cSql + STR(oRec.Field2,5,0) + ")"  && Field 2 contains a number, but we are creating a string here
>>>SQLEXEC(iCH,cSql)
>>>
Previous
Reply
Map
View

Click here to load this message in the networking platform