Visual Basic

  1. Home
  2. Computing & Technology
  3. Visual Basic
Using ADO .NET - First Principles
Part 4: The Xtra in ADO is XML!

One of the biggest differences between DataSet and the old Recordset is that data in ADO.NET is transported in XML format. That makes it a structured text document that can be read by anyone on any platform. This makes DataSet "interoperable" between a lot of computers - Microsoft and non-Microsoft since XML is an international and vendor neutral standard. After you create an XML document using methods provided by DataSet, you can parse it in .NET programmatically using the System.Xml.XmlDocument object.

Creating XML

ADO .NET makes it extremely easy to create XML documents. This is the only code you need to create a XML document where the principal customer contact is the owner using the Northwind sample database from Microsoft. Don't worry about all the new and unfamiliar code here ... we'll consider the details of this type of program in future articles.

' Declare the ADO .NET objects
Dim myData As New DataSet()
Dim myXML As String
Dim mySelectQuery As String = _
    "SELECT CompanyName FROM Suppliers"
Dim myConnection As New _
    OleDbConnection( _
    "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source={path}\Northwind.mdb")
Dim strSelect As String = _
    "SELECT * FROM Customers WHERE ContactTitle = 'Owner'"
Dim dsCmd As _
    New OleDbDataAdapter(strSelect, myConnection)
' Fill the DataSet object
dsCmd.Fill(myData, "CustomerOwners")
' Create a text XML document
myData.WriteXml("TestXML.txt")
myConnection.Close()

Once we have XML, virtually all computer environments are open to our data. The excellent support of ADO .NET and VB .NET for XML make interoperability a snap.

From XML to any system

In future articles, we'll dive into the coding details behind ADO .NET.

First page > Learning ADO .NET > Page 1, 2, 3, 4

Explore Visual Basic

By Category

About.com Special Features

Visual Basic

  1. Home
  2. Computing & Technology
  3. Visual Basic

©2009 About.com, a part of The New York Times Company.

All rights reserved.