>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