Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Making SQL Pass-Through Cursor Updatable
Message
De
05/03/2003 06:00:23
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
03/03/2003 18:29:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00760620
Message ID:
00761402
Vues:
29
>I'm having difficulty making an SPT cursor updatable. I tried two different ways:
>1) Connected to data source and called code from FAQ ID: 8153 (didn't copy all the text of that code)
>
>2) Attempted to issue the CURSORSETPROP command directly (2nd set of code)
>
>I changed the data in the cursor and issued a tableupdate without error. The data was never saved on the server.
>
>What am I doing wrong?
>
>Thanks,
>Monique
>
>---CODE---------------------------------------
>lnHandle=SQLCONNECT("RouteSQL","username","password")
>
>lcQueryStr="SELECT * FROM ROUTES"
>lcCursor="routeTmp"
>=SQLEXEC(lnHandle,lcQueryStr,lcCursor)
>
>* cCursor = Cursor name
>* cSourceTable = Source Table for data
>* cPK = Primary Key of Source Table
>* cFldList = List of fields to update (or All)
>cCursor="routeTmp"
>cSourceTable="dbo.routes"
>cPK="id"
>cFldList="Paginated"
>cUpdtList="Paginated dbo.routes.Paginated"
>-------------------------------------------------
>lSuccess=SetUpdate(cCursor, cPK, cSourceTable, "id,jobno,no",.f.)
>
>*(OR)
>
>=CURSORSETPROP("Tables",cSourceTable,cCursor)
>=CURSORSETPROP("KeyFieldList",cPK,cCursor)
>=CURSORSETPROP("UpdatableFieldList",cFldList,cCursor)
>=CURSORSETPROP("UpdateNameList",cUpdtList,cCursor)
>=CURSORSETPROP("Buffering",5,"routetmp")

In UpdateNameList remove owner identifier and add keyfield. ie:
cPK="id"
cFldList="Paginated"
cUpdtList="id routes.id,Paginated routes.Paginated"
lnHandle=Sqlstringconnect('DRIVER=SQL Server;SERVER=servername;'+;
   'DATABASE=pubs;Trusted_Connection=Yes')
SQLExec(lnHandle,'select * from dbo.authors','v_authors')
CursorSetProp('KeyFieldList','au_id','v_authors')
CursorSetProp('WhereType',1,'v_authors')
CursorSetProp('Tables','authors','v_authors')

CursorSetProp("UpdateNameList", ;
  "au_id    authors.au_id,"+;
  "au_lname authors.au_lname,"+;
  "au_fname authors.au_fname,"+;
  "contract authors.contract",'V_authors')

CursorSetProp('UpdatableFieldList','au_fname,au_lname,contract','v_authors')
CursorSetProp('SendUpdates',.T.,'v_authors')
CursorSetProp('Buffering',5,'v_authors')

Browse title "before Update - edit"
Tableupdate(2,.T.,'v_authors')
SQLExec(lnHandle,'select * from dbo.authors','afterupdate')
SQLDisconnect(lnHandle)
Select afterupdate
Browse title "After update"
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform