Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CursorAdapter Insert Failure
Message
From
23/06/2006 15:43:17
 
 
To
23/06/2006 13:24:03
Jarid Griesel
The Innovix Technology Group (Pty) Ltd
Johannesburg, South Africa
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01131208
Message ID:
01131297
Views:
18
I tried several times and worked fine all of them.

One question, did you tried using a primary key NOT made of 2 fields, only with one integer field? I tried that but it also runs with no error, as the previous one.
Why don't you try that?
Hernan

The following is your code but with an autoinc primary key, why don't you run it in your pc and see if it fails?

SET SAFETY OFF
CREATE TABLE caudclv2 (idcaudclv2 i autoinc, lv1code C(3), lv2code C(4), descr C(40))
INDEX ON lv1code + lv2code TAG "prikey"
SET SAFETY ON
**> define property values
pcKeyLst = "lv1code, lv2code"
pcFldLst = "idcaudclv2, lv1code, lv2code, descr"
pcDST = "NATIVE"

**> create the cursor adapter
poCA = CREATEOBJECT("CursorAdapter")
WITH poCA
.Alias = "c_caudclv2"
.AllowDelete = .T.
.AllowInsert = .T.
.AllowUpdate = .T.
.BufferModeOverride = 3
.CursorSchema = "idcaudclv2 i, lv1code C(3), lv2code C(4), descr C(40)"
.DataSourceType = pcDST
.DeleteCmdDataSourceType = pcDST
.InsertCmdDataSourceType = pcDST
.InsertCmdRefreshFieldList = pcFldLst
.InsertCmdRefreshKeyFieldList = pcKeyLst
.KeyFieldList = pcKeyLst
.RefreshCmdDataSourceType = pcDST
.RefreshIgnoreFieldList = ""
.SelectCmd = "SELECT * FROM caudclv2"
.SendUpdates = .T.
.Tables = "caudclv2"
.UpdateCmdRefreshFieldList = pcFldLst
.UpdateCmdRefreshKeyFieldList = pcKeyLst
.UpdateCmdDataSourceType = pcDST
.UpdatableFieldList = pcFldLst
.UpdateNameList = "lv1code caudclv2.lv1code, lv2code caudclv2.lv2code, descr caudclv2.descr"
.UseCursorSchema = .T.
.WhereType = 3
ENDWITH

*!* SET STEP ON

**> now run the cursor adapter and insert a record
CLEAR
CLEAR ERROR
? poCA.CurSorFill()
INSERT INTO "c_caudclv2" (lv1code, lv2code, descr) VALUES ("ADD", "ABC", "mary")
? RECCOUNT("c_caudclv2") && ca cursor
? RECCOUNT("caudclv2") && base table

IF TABLEUPDATE(0, .F., "c_caudclv2") = .F.
**> this always fails with error code 2166 -
**> "The refresh key for table caudclv2 is not found"
= AERROR(paErr)
LIST MEMORY LIKE paErr
ENDIF

? RECCOUNT("c_caudclv2") && ca cursor
? RECCOUNT("caudclv2") && base table

**> issuing table update again will succede ( it would seem because the base
**> table now has the record in it, how ever the second tableupdate command
**> duplicates the record in the data source table
? TABLEUPDATE(0, .F., "c_caudclv2")
? RECCOUNT("c_caudclv2") && ca cursor
? RECCOUNT("caudclv2") && base table
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform