Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQLEXEC with NoData Returned
Message
 
 
To
05/11/2007 10:03:22
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01266694
Message ID:
01266700
Views:
18
You should check return value from CursorFill. It'll return .F. if it fails. You can use AERROR() function to get underlying error.

You can make the SQLEXEC() cursor updatable as shown in How to make SQL Pass-Through cursor updatable FAQ #8153

>
>When using a Cursor Adapter class, I can set the NoData property to FALSE and an empty cursor is returned. My data backend happens to be SQL Server. I then use an APPEND to load the cursor with new data and then a TABLEUPDATE(.t.) to move the data back to SQL Server for storage in the host table.
>
>
>lo_metrics_log_cad = CREATEOBJECT("metrics_log_cad")
>lo_metrics_log_cad.NoData = (( .t. ))
>lo_metrics_log_cad.CursorFill() && Produces csr_metrics_log as a cursor
>...
>SELECT csr_metrics_log && My SQL Server cursor
>APPEND FROM metrics_log && My local log data in a local DBF file (C:\TEMP)
>TABLEUPDATE( (( .t. )) ) && Stores my data over to SQL Server
>
>
>
>
>There are times when, for whatever reason, the Cursor Adapter fails and does not return a cursor. I do not understand why this is. However, I have noted that I NEVER have a failure when using SQLEXEC(). So, as you might surmise, I'd like to use SQLEXEC exclusively because in this application, I CANNOT have this function fail.
>
>Still, I have a problem. I do not know how, with SQLEXEC() to return a NoData empty cursor, which I can then INSERT records in to and update my SQL Server backend with TABLEUPDATE(.t.).
>
>I have tried using something like
>
>
SELECT TOP 0 * FROM tab_metrics_log
>
>In SQL Server Query Analyzer, this returns what I expect: An empty cursor. However, when I issue the SQL through SQLEXEC it fails to return an updateable cursor (i.e. I cannot APPEND and then TABLEUPDATE(.t.) and get the records to move back to SQL Server successfully).
>
>What am I doing wrong?
>
>Thank you in advance! :-)
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform