Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How To Persist an ADO.NET DataSet as XML by Using Visual Basic .NET

30 views
Skip to first unread message

jenny wilkinson

unread,
Aug 2, 2012, 7:34:25 AM8/2/12
to
This post is inspired by the excellent work from the Visual Basic Team from msdn, thank you for all of your good VB resources and worked suggestions.

This post will illustrate the best way to persist an ADO.NET DataSet object to XML.

To write your XML you should use the WriteXml option to write schema and data from the DataSet object. The XML data is published to a file, a Stream class, an XmlWriter class, or a TextWriter class.

Dependant upon what exactly your requirements are, it is possible to employ one of two sets of overloaded methods for WriteXml. Your very first set of four overloaded methods actually takes precisely one parameter, also, the second set of four overloaded methods takes an additional parameter (XmlWriteMode) and as well additionally takes one of the above-mentioned parameters.

I am planning to explain each one of these methods within this section.

For creating the current schema and the data for the DataSet to the particular file, you should employ the following code:

Overloads Public Sub WriteXml(String)

For the purpose of producing the present schema and data for the DataSet, you need to use the specified TextWriter class. The TextWriter class is made for character output.

Overloads Public Sub WriteXml(TextWriter)

If you wish to generate to your current schema as well as data for the DataSet, you will have to makes use of the specified System.IO.Stream. The Stream class is for byte input and output.

Overloads Public Sub WriteXml(Stream)

And Then Finally, to create your current schema and data for the DataSet to the specified XmlWriter, you should employ the subsequent code.

Overloads Public Sub WriteXml(XmlWriter)

This procedure gives you a incredibly rapid, non-cached, forward-only method to develop streams or files that contain XML data that is fully compliant and legal to W3C XML 1.0 specification and the namespaces in the XML specification.

To speed up your XML Visual Basic job you may also make use of a parser, validator tool like Liquid XML Studio which also contains a code generation function (http://www.liquid-technologies.com/xmldatabinding/xml-schema-to-vb.aspx) to automatically crank out visual basic code according to your xml or schema.
0 new messages