Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Correct Syntax to SQL Server thru ODBC from VFP
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00929617
Message ID:
00930109
Views:
16
Hi Bernard,
Thanks for the info, but I have tried this with the field list, and I still get an error on the value data. My statement after being built looks like this:
" Insert into temptable (col1) values ("BAR.0000")"
and it still thinks the value "BAR" is a column name.
Since this is Monday, I may just toss the program out the window and come back to it when I have settled down .



>Hi Beth:
>
>You need a parameterized insert statement. Works well on any data type and even if your field values have quotes. I would do something like:
>
>
>lcTableName = "tablename"
>lcFieldValues = "?pcFieldValue1, ?pcFieldValue2, ?pcFieldValue3"
>lcSqlStr = "insert into " + lcTableName + " values(" + lcFieldValues + ")"
>
>
>The field values are variables that must at least be private in scope.
>Also, in the insert statement I find it better to explicitly define the target fields. I.e.,
>
>lcFieldList = "FieldName1, FieldName2, FieldName3"
>lcSqlStr = "insert into " + lcTableName + "(" + lcFieldList + ") " + ;
>    "values(" + lcFieldValues + ")"
>
>
>HTH
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform