Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CursorAdaptor / XMLAdaptor
Message
From
06/08/2003 00:32:06
 
 
To
05/08/2003 13:57:29
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00816919
Message ID:
00817171
Views:
34
Hi Aleksey,

The code below is very similar to your code. The "catest" class is a CursorAdapter class which works fine when configured as an SQL Server ODBC connection to the Northwind database. However, if configured as an ADO connection, the error "Ole object is invalid or corrupt" is thrown at loXA.Tables(1).ApplyDiffGram("", loCA) shown below. I should have been more specific in my original message.
LOCAL loCA AS CursorAdapter, loXA AS XMLAdapter, lcXML AS String

loCA = NEWOBJECT("catest", "c:\program files\microsoft visual foxpro 8\testit.vcx")
loCA.CursorFill()
loXA = CREATEOBJECT("XMLAdapter")
loXA.AddTableSchema("cursor1")
loXA.ToXML("lcXML")
RELEASE loCA
RELEASE loXA

loXA = CREATEOBJECT("XMLAdapter")
loXA.LoadXML(lcXML)
loXA.Tables(1).Alias = "cursor1"
loXA.Tables(1).ToCursor()

SELECT cursor1
CURSORSETPROP("Buffering", 5)
REPLACE contactname WITH ALLTRIM(contactname) + " - Howdy!"

loXA.ReleaseXML(.F.)
loXA.IsDiffgram = .T.
loXA.toXML("lcXML","",.F.,.T.,.T.)
RELEASE loXA
USE IN cursor1

loXA = CREATEOBJECT("XMLAdapter")
loXA.LoadXML(lcXML)
loCA = NEWOBJECT("catest", "c:\program files\microsoft visual foxpro 8\testit.vcx")
loXA.Tables(1).ApplyDiffGram("", loCA)

RELEASE loXA
RELEASE loCA
>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.
- Jeff
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform