Thursday, March 22, 2012

Dataset or SqlCommand or SQLXML

I am in a dilemma(rather "trilemma"!!!).
I have a Microsoft SQL 2000 Server and I want to retrieve data from the
server in XML format. Can do it without even utilizing the special XML
capabilites of SQL 2000 server.
I mean I can very well use:
1. Store the data retieved from the DB in a dataset and use WriteXML()
function.
2. Use SQLExecuteReader() function of SqlCommand class
Is their some advantage/need(may be performance issues etc.) to use SqlXml
managed classes for *only* conversion of data retrieved from SQL server to
XML format?
Also in case we dont have SQL 2000 server (suppose an earlier version or a
non-Microsoft DB) then too the aforelisted 2 methods for accessing XML data
would work...are'nt they?
Suggestions/comments invited.
-Aayush
What you say is partially correct - if you simply want to convert the
relational data to XML, you can do it using the WriteXml method of a
DataSet.
As regards your second option, I assume you mean the ExecuteXmlReader method
of SqlCommand - and this will only work with a FOR XML query against SQL
Server 2000 - so you couldn't use this approach with other data sources.
See http://www.microsoft.com/mspress/boo...#SampleChapter
for a comparison of using "standard" ADO.NET vs SqlXml classes. There are
quite a few advantages to using the SqlXml classes if your data is in SQL
Server 2000 - I guess it depends whether or not you need the additional
flexibility and functionality they offer.
Cheers,
Graeme
--
Graeme Malcolm
Principal Technologist
Content Master Ltd.
www.contentmaster.com
www.microsoft.com/mspress/books/6137.asp
"Aayush Puri" <aayush@.nospam.com> wrote in message
news:%23VXfr16TEHA.2716@.tk2msftngp13.phx.gbl...
I am in a dilemma(rather "trilemma"!!!).
I have a Microsoft SQL 2000 Server and I want to retrieve data from the
server in XML format. Can do it without even utilizing the special XML
capabilites of SQL 2000 server.
I mean I can very well use:
1. Store the data retieved from the DB in a dataset and use WriteXML()
function.
2. Use SQLExecuteReader() function of SqlCommand class
Is their some advantage/need(may be performance issues etc.) to use SqlXml
managed classes for *only* conversion of data retrieved from SQL server to
XML format?
Also in case we dont have SQL 2000 server (suppose an earlier version or a
non-Microsoft DB) then too the aforelisted 2 methods for accessing XML data
would work...are'nt they?
Suggestions/comments invited.
-Aayush