Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CursorAdaptor / XMLAdaptor
Message
De
06/08/2003 00:32:06
 
 
À
05/08/2003 13:57:29
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00816919
Message ID:
00817171
Vues:
35
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform