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:
01227338
Vues:
33
Your code works, but mine doesn't. I'm using a CursorAdapter with free tables. This is giving me an error:
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 worder10"
oCA.UpdatableFieldList="custno"
oCA.UpdateNameList = "custno worder10.custno"
oCA.Tables="worder10"
*oCA.KeyFieldList = "ID"
oCA.Alias="WOrderCursor"
oCA.CursorFill()
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.

Any help would be appreciated.


>Hi Tim,
>
>Default values should work, at least they work in the code below. The code shows several scenarios when the error is expected and how to avoid it. When your "remote" source is VFP, you have an option to SET NULL OFF for the connection, then BLANK values will be used for not-assigned fields. BTW, VFP ODBC driver wasn't updated for a log time and there are some bugs that you can run into with it. I recommend you to use VFPOLEDB provider instead. If you decide to stay with VBPODBC, do not use BackgroundFetch=Yes setting.
>
>Thanks,
>Aleksey.
>
>
>CLOSE DATABASES all
>CLEAR
>SET MULTILOCKS ON
>SET NULL ON
>?VERSION()
>?
>CREATE CURSOR test (f1 I NOT NULL, f2 I NOT NULL)
>
>LOCAL oCA as CursorAdapter
>
>oCA=CREATEOBJECT("CursorAdapter")
>oCA.DataSourceType="NATIVE"
>oCA.SelectCmd="SELECT f1 FROM test"
>oCA.UpdatableFieldList="f1"
>oCA.Tables="test"
>oCA.UpdateNameList="f1 test.f1"
>oCA.Alias="testCA"
>
>? "Reason #1: The field isn't selected from the table"
>?oCA.CursorFill()
>SELECT testCA
>APPEND BLANK
>REPLACE f1 WITH 1
>IF !TABLEUPDATE()
>	AERROR(aerrs)
>	?aerrs[1,2]
>	TABLEREVERT()
>ENDIF
>?
>? "Reason #2: The field isn't included into UpdatableFieldList and/or UpdateNameList"
>oCA.SelectCmd="SELECT f1,f2 FROM test"
>?oCA.CursorFill()
>SELECT testCA
>INSERT INTO testCA VALUES (2,2)
>IF !TABLEUPDATE()
>	AERROR(aerrs)
>	?aerrs[1,2]
>ELSE
>	? "Unexpected."
>ENDIF
>?"Let's include it: "
>oCA.UpdatableFieldList="f1, f2"
>oCA.UpdateNameList="f1 test.f1, f2 test.f2"
>IF !TABLEUPDATE()
>	AERROR(aerrs)
>	??aerrs[1,2]
>	TABLEREVERT()
>ELSE
>	?? "TABLEUPDATE succeeded"
>ENDIF
>?
>? "Reason #3: The field isn't modified"
>SET NULL OFF
>INSERT INTO testCA (f1) VALUES (3)
>SET NULL ON
>IF !TABLEUPDATE()
>	AERROR(aerrs)
>	?aerrs[1,2]
>ELSE
>	? "Unexpected."
>ENDIF
>? "Let's modify the field: "
>REPLACE f2 WITH 3
>IF !TABLEUPDATE()
>	AERROR(aerrs)
>	??aerrs[1,2]
>	TABLEREVERT()
>ELSE
>	?? "TABLEUPDATE succeeded"
>ENDIF
>? "Let's use DEFAULT value: "
>oCA.CursorSchema = "f1 I, f2 I DEFAULT 4"
>oCA.CursorFill(.T.)
>SELECT testCA
>SET NULL OFF
>INSERT INTO testCA (f1) VALUES (4)
>SET NULL ON
>IF !TABLEUPDATE()
>	AERROR(aerrs)
>	??aerrs[1,2]
>	TABLEREVERT()
>ELSE
>    ?? "TABLEUPDATE succeeded"
>ENDIF
>?
>TABLEREVERT()
>?ALIAS()
>LIST
>?
>SELECT test
>?ALIAS()
>LIST
>
>
>Result:
>
>
>Visual FoxPro 09.00.0000.3504 for Windows
>
>Reason #1: The field isn't selected from the table
>.T.
>Field F2 does not accept null values.
>
>Reason #2: The field isn't included into UpdatableFieldList and/or UpdateNameList
>.T.
>Field F2 does not accept null values.
>Let's include it: TABLEUPDATE succeeded
>
>Reason #3: The field isn't modified
>Field F2 does not accept null values.
>Let's modify the field: TABLEUPDATE succeeded
>Let's use DEFAULT value: TABLEUPDATE succeeded
>
>TESTCA
>Record#           F1          F2
>      1            2           2
>      2            3           3
>      3            4           4
>
>
>TEST
>Record#           F1          F2
>      1            2           2
>      2            3           3
>      3            4           4
>
eCost.com continues to rip people off
Check their rating at ResellerRatings.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform