Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using CursorAdapters
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00754017
Message ID:
00754027
Vues:
23
Hi Craig,

Here is an example:
oCsr=CREATEOBJECT('CursorAdapter')
oCsr.DataSourceType="NATIVE"
oCsr.SelectCmd="SELECT * FROM '"+ADDBS(HOME())+"Samples\Northwind\customers' where customerid='A'"
oCsr.Alias="Northwind_Customers"
oCsr.CursorFill()
The main problem is that you didn't specify the DataSourceType and you misunderstood the concept of CursorAttach. With CursorAttach, you attach a Cursor (as in a View) to the Adapter so that all tableupdates of that Cursor will use the settings en code of the CursorAdapter. If you want to specify the tables for a given SelectCmd, so that you can update them, put them in the tables property.
Here is an example of an Updatable CursorAdapter:
oCsr=CREATEOBJECT('CursorAdapter')
oCsr.DataSourceType="NATIVE"
oCsr.SelectCmd="SELECT * FROM '"+ADDBS(HOME())+"Samples\Northwind\customers' where customerid='A'"
oCsr.Tables="customers"
oCsr.Alias="Northwind_Customers"
oCsr.CursorSchema="CUSTOMERID C(5), COMPANYNAME C(40), CONTACTNAME C(30), CONTACTTITLE C(30), ADDRESS C(60), CITY C(15), REGION C(15), POSTALCODE C(10), COUNTRY C(15), PHONE C(24), FAX C(24)"
oCsr.KeyFieldList="CUSTOMERID"
oCsr.UpdateNameList="CUSTOMERID CUSTOMERS.CUSTOMERID, COMPANYNAME CUSTOMERS.COMPANYNAME, CONTACTNAME CUSTOMERS.CONTACTNAME, CONTACTTITLE CUSTOMERS.CONTACTTITLE, "+"ADDRESS CUSTOMERS.ADDRESS, CITY CUSTOMERS.CITY, REGION CUSTOMERS.REGION, POSTALCODE CUSTOMERS.POSTALCODE, COUNTRY CUSTOMERS.COUNTRY, PHONE CUSTOMERS.PHONE, FAX CUSTOMERS.FAX"
oCsr.UpdatableFieldList="CUSTOMERID, COMPANYNAME, CONTACTNAME, CONTACTTITLE, ADDRESS, CITY, REGION, POSTALCODE, COUNTRY, PHONE, FAX"
oCsr.WhereType= 1 &&DB_KEY
oCsr.CursorFill()
REPLACE country WITH IIF(country="Germany","The Netherlands","Germany") FOR CUSTOMERID="ALFKI"
TABLEUPDATE(.t.)
? _Tally
I Used _Tally here because that one will give you the amount of records updated with the TableUpdate.

>Just taking a look at CursorAdapters, but can't seem to attach a native data source. Sure I am missing something simple:
>
>
oCsr = CREATEOBJECT('CursorAdapter')
>oCsr.CursorAttach('Test')  && where Test is a local VFP table
>oCsr.SelectCmd = 'SELECT * FROM Test'
>oCsr.CursorFill()
>
>
>at this stage, the cursor has not been attached. Not sure what is missing?

hth,
Frank Camp
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform