Saving DataSet as XML in ADO format using VB.NET

S

Shaileen Patel

Hi,

I am trying to convert a lot of web reports from ASP/VB to
ASP.NET/VB.NET. I would like to save my dataset in XML and then use
XSLT to transform the XML. The catch is I would like to have the XML
in the format that ADO uses versus the default format in which ADO.NET
uses. Currently, I am using ADO within .NET, but I am concerned about
the performance and it might improve if I used the native data
providers for .NET. I am not sure if I am missing something but how do
I save the .NET DataSet to XML in the OLD ADO format?


Thanks for you help in advance and it is most appreciated.


In the old version fo the reports, the code is as follows:

Set lobjConnection = New ADODB.Connection
lobjConnection.ConnectionString = mstrConnectionString
lobjConnection.CursorLocation = adUseClient
lobjConnection.Open

Set lobjRecordset = lobjConnection.Execute(pstrSQL)
Set lobjDom = New MSXML2.DOMDocument40
lobjRecordset.Save lobjDom, 1

Set lobjXSL = New MSXML2.DOMDocument40
lobjXSL.Load (pstrXSLFilePath)
lstrHTML = (lobjDom.transformNode(lobjXSL))

The sample of XML from the old version of the reports is as follows:

<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<s:Schema id="RowsetSchema">
--"Schema Information"--
</s:Schema>
<rs:data>
<z:row PENDING_CODE="001" PEND_CODE_DESCR="Missing Note Date"/>
</rs:data>
</xml>

In the new version of the reports, using the native data provider, the
code is as follows:

Dim lobjDA As OracleDataAdapter
Dim lobjCmdBuilder As OracleCommandBuilder
Dim lobjDS As DataSet
Dim lobjXMLDataSet As XmlDataDocument

mobjConn = New OracleConnection(GetDSNFromCache())
mobjConn.Open()
mobjCmd = New OracleCommand(astrSQL, mobjConn)
lobjDA = New OracleDataAdapter(mobjCmd)
lobjCmdBuilder = New OracleCommandBuilder(lobjDA)
lobjDA.MissingSchemaAction = MissingSchemaAction.Add

lobjDS = New DataSet("DataSet")
lobjDS.Tables.Add("Results")
lobjDA.Fill(lobjDS, "Results")
lobjXMLDataSet = New XmlDataDocument(lobjDS)

Return lobjXMLDataSet.InnerXml

The sample of XML from the newversion of the reports is as follows:
<DataSet><Results><PENDING_CODE>001</PENDING_CODE><PEND_CODE_DESCR>Missing
Note Date</PEND_CODE_DESCR></Results></DataSet>
 
C

Cor

Hi Shaileen,

Do not hit your desk in two when you read this.

Instead of using the DOM you can use

dataset.xmlread and dataset.xmlwrite

Very overloaded methods with schemas

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top