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()
>...
>SELECT csr_metrics_log
>APPEND FROM metrics_log
>TABLEUPDATE( (( .t. )) )
>
>
>
>
>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--