Russell,
>Your code works, but mine doesn't. I'm using a CursorAdapter with free tables. This is giving me an error:
>The error occurs when I browse WOrderCursor, change a CUSTNO value and attempt the update. It says "No key columns are specified for the update table WORDER10. Use the KeyFieldList property of the cursor." It's a bit confusing. I don't think I had any problems like this with tables in a DBC.
The error you're getting is a "spoof message" -- the error message really doesn't directly point to your problem. You need to set the oCA.KeyFieldList property (uncomment the line in your program) and you can remove the CursorSetProp business at the top -- not needed.
What is missing is that your oCA.UpdateNameList property MUST include a cross-reference for the key field in addition to the updatable fields. Try this code:
release oCA
close all
clear all
set multilocks on
public oCA
oCA=CREATEOBJECT("CursorAdapter")
oCA.DataSourceType="NATIVE"
oCA.SelectCmd="SELECT id, custno, wono FROM data\branch10\worder10"
oCA.UpdatableFieldList="custno"
oCA.UpdateNameList = "id worder10.id, custno worder10.custno"
oCA.Tables="worder10"
oCA.KeyFieldList = "ID"
oCA.Alias="WOrderCursor"
oCA.CursorFill()
If you browse the resulting query and make changes to custno, you should see the base table being updated as you move around in the grid (because your updatable cursor has the default Optimistic Row Buffering, or when you call TableUpdate() if you set oca.BufferModeOverride=5 for table buffering (my preference).
NOTE: It is not necessary to open the table before calling the CursorAdapter, as long as you include the path to the data in the SelectCmd (or have a path set in your app that allows VFP to find the data).