Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Another CursorAdapter Problem
Message
From
16/05/2005 13:18:18
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01014610
Message ID:
01014619
Views:
27
Kevin,

>Can I open a table, create a CA, and update the base tables using it, even
>if I didn't get the data through the CA?

Yes, you should be able to do that. The update mechanisms are not tied to the way the data was put into the cursor and depend entirely on the CA properties related to updating and the buffered contents of the cursor currently attached.

>Here's my code, which doesn't work:

In your code, I don't see where you are putting anything INTO the temp table AFTER you set the buffering on it, which is the only way to get it automatically updated into the syserrors table. CursorAdapter will create update, insert or delete statements for any records that have changed in the attached buffered cursor (whether they were changed while attached or not), but only for those records added, updated or deleted in the cursor AFTER you turned on the buffering on the table/cursor.

It looks like what you want to do is initialize the CursorAdapter and configure it to write to the syserrors table, then get an initial "errdata" cursor with no data in it with .CursorFill(.F., .T.) -- the second parameters says get me an empty cursor -- then SELECT errdata and APPEND FROM temp (where presumably you have some records you want to get into syserror, then TABLEUPDATE(1) to write the newly appended records from the errdata cursor back to the syserrors table.

...unless I'm completely misunderstanding what you want to accomplish. :-)


>
>
>
>CLOSE DATABASES all
>local oCursor as CursorAdapter, aErrors[1]
>
>SELECT 0
>use	d:\projects\testdata\smts\syserrors
>
>SELECT 0
>use	Temp
>cursorsetprop("buffering", 5)
>
>oCursor = CREATEOBJECT("CursorAdapter")
>
>with oCursor
>
>   .Alias              = "errdata"
>   .BufferModeOverride = 5
>   .DataSourceType     = "Native"
>   .SelectCmd          = "select * from syserrors"
>   .KeyFieldList       = "recordid"
>   .Tables             = "syserrors"
>   .UpdatableFieldList = "recordid, error, line"
>   .UpdateNameList     = "recordid syserrors.recordid, error syserrors.error, line syserrors.line"
>
>   if .CursorFill()
>
>		.CursorAttach("Temp", .T.)
>		
>		SELECT Temp
>     TABLEUPDATE(1)
>
>   else
>
>     aerror(aErrors)
>     messagebox(aErrors[2])
>
>   endif
>
>endwith
>
>RETURN
>
David Stevenson, MCSD, 2-time VFP MVP / St. Petersburg, FL USA / david@topstrategies.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform