Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Update Access Tables from VFP
Message
From
04/09/2006 13:14:52
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Jet/Access Engine
Miscellaneous
Thread ID:
01150648
Message ID:
01150743
Views:
23
>>TEXT TO sqlcommand TEXTMERGE NOSHOW
>> INSERT INTO Table1 VALUES('first','second')
>>ENDTEXT
>>
> Vladimer,
>
>This works! However when I chnge the above line to
>
>INSERT INTO Table1 FROM MEMVAR
>
>I get an ODBC connectivity error. I vaguely recall that there is something special that needs to be done with the TEXT TO command to perform something like macro substitution.
>Any hints?

The memvar thing won't work, because you aren't sending them to the ODBC driver - you're sending text. Therefore, you need to give it text. There are several ways to convert your variables into text. One is to use VFP's automatic conversion:
TEXT TO sqlcommand TEXTMERGE NOSHOW
    INSERT INTO Table1 VALUES(?mvar1,?mvar2)
ENDTEXT
Note that the variables need to be in scope when SqlExec() call is executed.

Another way is to roll your own conversion, i.e. have a function which would return a proper string representation of anything:
TEXT TO sqlcommand TEXTMERGE NOSHOW
    INSERT INTO Table1 VALUES(<<toString(mytable.field1)>>,<<toString(mytable.field2)>>)
ENDTEXT
Formatting may be quite straightforward - you need quotation marks around the strings, numbers as they come out of str() function, but you may need to find out the proper format for logicals, dates, datetimes and memos. Memos may go as strings, but if they contain carriage returns and/or other nonprintables, this may be a problem.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform