Writing a DataSet's Contents to an XML File

Congratulations, you have succesfully written the contents of the ASPFAQs.com Popularity Listing stored procedure to an XML file, which can be seen below.



Source Code

<%@ import Namespace="System.Data.SqlClient" %>
<%@ import Namespace="System.Data" %>
<script runat="server">
    sub Page_Load(sender as Object, e as EventArgs)
        Dim myDataSet as New DataSet()
    
        
        'populate the dataset
        '1. Create a connection
        Dim myConnection as New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
		
        '2. Create the data adapter
        Dim myDA as New SqlDataAdapter("sp_Popularity", myConnection)
		
        '3. fill the dataset		
        myDA.Fill(myDataSet)
    
        'Write the dataset content out to disk as an XML file
        myDataSet.WriteXml(Server.MapPath("popularFAQs.xml"))
        
    end sub
</script>

<html>
<body>
  <h1>Writing a DataSet's Contents to an XML File</h1>
  Congratulations, you have succesfully written the contents of the <a href="http://www.aspfaqs.com/ASPFAQS/ViewPopular.asp">ASPFAQs.com
  Popularity Listing</a> stored procedure to an XML file, which can be seen below (if you browser supports
  IFRAMEs... if it doesn't, feel free to <a href="/demos/popularFAQs.xml">navigate directly to the XML file</a>).
  <p><hr><p>
  <ifram src="/demos/popularFAQs.xml" />

  


Return to the article