.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Articles >> .Net Framework >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Using an XmlReader

Posted By:Shashi Ray       Posted Date: November 27, 2009    Points: 10    Category: .Net Framework    URL: http://www.dotnetspark.com  


Using an XmlReader

Use an XmlReader obtained by calling the ExecuteXmlReader method of the SqlCommand object when:

  • You want to process the retrieved data as XML, but you do not want to incur the performance overhead of creating a DataSet and do not require a disconnected cache of data.
  • You want to exploit the functionality of the SQL Server 2000 FOR XML clause, which allows XML fragments (that is, XML documents with no root element) to be retrieved from the database in a flexible manner. For example, this approach lets you specify precise element names, whether an element or attribute-centric schema should be used, whether a schema should be returned with the XML data and so on.

More Information

If you use the XmlReader, note the following:

The connection must remain open while you read data from the XmlReader. The ExecuteXmlReader method of the

SqlCommand object currently does not support the CommandBehavior.CloseConnection enumerated value, so you must

explicitly close the connection when you finish with the reader



Shashi Ray

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend