Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CursorAdaptor / XMLAdaptor
Message
From
05/08/2003 13:57:29
 
 
To
05/08/2003 11:41:23
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00816919
Message ID:
00816987
Views:
32
>How can a CursorAdapter be updated with a DiffGram created by an XMLAdapter? According to the XMLTable ApplyDiffGram method, you should be able to do this by passing a CA object reference parameter as follows:
>
>oxaTest.Tables(1).ApplyDiffGram("cursor1", ocaTest, .T.)
>
>I get an error with the above. I can't find an example of how to do this properly. If anyone has a suggestion on how a CA can be updated with a DiffGram, it would be more than appreciated.

Hi Jeff,

Here is an example how to use ApplyDiffgram method:
CLOSE DATABASES all
SET MULTILOCKS ON
CLEAR

lCustomCursorAdapter=.F.   && change to .T. to use custom CursorAdapter object

CREATE CURSOR foo1 (f1 I, f2 c(10))
INSERT INTO foo1 VALUES (1,"1111")
INSERT INTO foo1 VALUES (2,"2222")
?ALIAS()
LIST 

LOCAL oXA as XMLAdapter

oXA=CREATEOBJECT("XMLAdapter")
oXA.AddTableSchema("foo1")
oXA.ToXML("cXML")
oXA=null

oXA=CREATEOBJECT("XMLAdapter")
oXA.LoadXML(cXML)
oXA.Tables(1).Alias="foo2"
oXA.Tables(1).ToCursor()

SELECT foo2
CURSORSETPROP("Buffering",5)


UPDATE foo2 SET f2=RTRIM(f2)+"*"


oXA.ReleaseXML(.F.)
oXA.IsDiffgram= .T.
oXA.ToXML("cXML","",.F.,.T.,.T.)
oXA=null


oXA=CREATEOBJECT("XMLAdapter")
oXA.LoadXML(cXML)


IF lCustomCursorAdapter
	LOCAL oCA as CursorAdapter
	oCA=CREATEOBJECT("CursorAdapter")
	
	&& configure CA for update
	oCA.DataSourceType="NATIVE"
	oCA.Tables="foo1"
	oCA.UpdatableFieldList="f1,f2"
	oCA.KeyFieldList="f1"
	oCA.UpdateNameList="f1 foo1.f1, f2 foo1.f2"
	
	? "ApplyDiffgram using custom CA."
	oXA.Tables(1).ApplyDiffgram("",oCA)
ELSE
	&& XMLAdapter is smart enough to handle simple case without custom CursorAdapter
	&& mark key fields otherwise all fields are treated as key fields
	oXA.Tables(1).Fields(1).Keyfield=.T.

	? "ApplyDiffgram using default XMLAdapter behavior."
	oXA.Tables(1).ApplyDiffgram()
ENDIF

SELECT foo1
?ALIAS()
LIST


return
Thanks,
Aleksey.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform