Serializing DataSets to XML

As mentioned in the preceding section, DataSets are represented internally by XML. Therefore, it is particularly easy to transfer a DataSet to an XML document and also to reverse the process.

Viewing the Contents of a DataSet

The example in Listing 10.3 uses the GetXml() method of the DataSet object to return the DataSet's contents in XML form as a string. First, a table of information is retrieved from the Customers table in the Northwind database. Then it is placed into a label Web control in a Web form in order to display it.

Listing 10.3. Viewing the Contents of a DataSet
 <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <HTML> <HEAD> <script language="VB" runat="server" > Sub ...

Get Sams Teach Yourself ADO.NET in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.