Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Passthru
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Title:
Miscellaneous
Thread ID:
00719981
Message ID:
00720046
Views:
18
I am trying to write to a table using SQL Passthru from a record object created from the scatter command. I basically scattering to an object modifying the properties and wish to insert the changes back.

I can't build the text because in some cases the values include quotes and such, but even in the most simple cases it is not working.

oRec.Field1 = 'Test1'
oRec.Field2 = 123

if I do:
sqlexec(iCH,'insert into table (field1,field2) values (oRec.Field1,oRec.Field2)

the record is inserted, but the field are blank

if I do:

sqlexec(iCH,insert into table (field1,field2) values (?oRec.field1, oRec.Field2)

I get a returned (-1) where the aerrors method tells me:
Connectivity error: [Microsoft][ODBC Visual FoxPro Driver]Data type mismatch.


Hey Troy! How you been? Hope everything is going well for you.

I see what you're doing. At first glance I thought your syntax should work but after waking up and looking at it a little more carefully it seems that you're trying to pass the VFP Objects to SQL Server or probably even passing literal values of "oRec.Field1"

What you may have to try is to concatenate the string and pass it as a variable to the Sql Server. Such as:

cSql = "Insert into table(field1, fields2) values ("
cSql = cSql + oRec.Field1 + ", "
cSql = cSql + oRec.Field2 + ")"
SQLEXEC(iCH,cSql)

Hope this helps - Take care and see ya 'round.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform