Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Output to XML File
Message
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Miscellaneous
Thread ID:
00955934
Message ID:
00956510
Views:
11
Thanks anyway Sergey, I've just found a way to make it work. My problem was that I wasn't really sure how XML works with SQL Server. However, I've found an article in MSDN that made things clear to me and from that I was able to solve my problem.

For future reference, here's the code:
CREATE CURSOR Test (myField M) &&& Temp cursor to hold the XML data
APPEND BLANK 
#INCLUDE ENCABEZADOS.H  &&& Header file with the ADO constants def.
#Define adExecuteStream 0x400  

cConnString='provider=SQLXMLOLEDB.3.0;data provider=SQLOLEDB;Persist Security Info=False;User ID=sa;Initial Catalog=Data001;Data Source=ibm600e'

oTestStream=CREATEOBJECT("ADODB.Stream")
oTestConnection=CREATEOBJECT("ADODB.Connection")
oTestCommand=CREATEOBJECT("ADODB.Command")
oTestCommand.CreateParameter("FechaFin", 130, 1, 10, DTOS(DATE()))
oTestConnection.Open(cConnString)
oTestCommand.ActiveConnection = oTestConnection
oTestCommand.Properties("ClientSideXML") = .T.
oTestCommand.CommandText = "P_ESTADOCTAGEN"
oTestCommand.CommandType= adCmdStoredProc

oTestStream.Open()
oTestCommand.Properties("Output Stream").Value = oTestStream
oTestCommand.Properties("xml root") = "root"
oTestCommand.Execute( , , adExecuteStream)

oTestStream.Position = 0
oTestStream.Charset = "utf-8"

Replace Test.MyField WITH  oTestStream.ReadText()

XMLTOCURSOR(Test.myField,"curXMLData")
Sorry if I was such a PITA :)

Enmanuel




>Hi Enmanuel,
>
>Your story keeps changing all the time which makes it imposible to help you. Make your mind and come back when ready. :)
>
>>Yes I know it's odd what I'm asking :) but I still got this SP that returns several RS to an ADO object and I'm getting an error trying to read the second RS with the ADO NextRecordset method because the 2nd RS it's a SQL table data type variable and therefore closed after the SP terminate executing. I thought of just save the recordset into a temp file and read it from there.
>
>>>I still not sure why do you want to retrieve recordset instead of getting XML directly from SQL Server using 'FOR XML' clause. Anyway, you can conver returned cursor into XML using XMLTOCURSOR() function.
>>>
>>>>Sorry if I did not make myself clear. All I want is to save the records returned by the select statement into a XML file in the client computer. Let's say I have the following statement:
>>>>
>>>>
>>>>  Select * From Employees
>>>>
>>>>
>>>>Then I want all the records from the Employees table to be saved into a XML file named C:\myXMLFiles\Employees.xml, for example.
>>>>
I'm a mixture of Albert Einstein and Arnold Schwarzenegger. The only trouble is that I got Einstein's body and Schwarzenegger's brain
Previous
Reply
Map
View

Click here to load this message in the networking platform