Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Updating CursorAdapter w/Free Tables
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01161323
Message ID:
01227419
Vues:
36
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
*use data\branch10\worder10
*? cursorsetprop("KeyFieldList", "id", "worder10")
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"
* NOTE: Optional for table buffering instead of row buffering
* oCA.BufferModeOverride = 5
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).
David Stevenson, MCSD, 2-time VFP MVP / St. Petersburg, FL USA / david@topstrategies.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform