Create an XML on the fly from a Dataset

Contributed by
Rating: 5 stars5 stars5 stars5 stars5 stars / 6
November 08, 2001
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

Create XML file from a dataset


Webpage code

<%@ Page EnableSessionState="False" EnableViewState="False" debug="False" trace="False" strict="True" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.Xsl" %>

<script language=VB runat=server>
'Path where the xml file will be created
private const m_XmlFile as String = "c:\inetpub\wwwroot\newfile.xml"

Sub Page_Load(Sender As Object, E As EventArgs) 

'Create Connection and DataSet Objects
Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("DSN_pubs"))
Dim ds as DataSet = new DataSet()
dim sSql as string = "SELECT * FROM Authors"

'Declare an Adapter and Fill Dataset
dim adapter as SqlDataAdapter = new SqlDataAdapter(sSql, myConnection)
adapter.Fill(ds,"WhatsNew")
myConnection.Close() 

'One line of code to create an xml file
ds.WriteXml(m_XmlFile, XmlWriteMode.IgnoreSchema)

End Sub

</script>
<html>
<head></head>
<body>

File Created!

</body>
</html>

blog comments powered by Disqus
ASP.NET CODE ARTICLES

- How to Use the ListBox Control in ASP.NET 2.0
- How to Load XML Documents in ASP.NET 2.0
- DataGrid Code
- ASP.NET Guestbook
- User Controls and Client Side Scripting
- ASP.NET Programming with Microsoft's AS...
- ASP.NET Basics (part 3): Hard Choices
- ASP.NET Basics (part 2): Not My Type
- ASP.NET Basics (part 1): Nothing But .Net
- Directory Tree Browser
- How to get the confirmation of Yes/No from a...
- Complete example using custom errors and wri...
- Paging Certain # records per page .NET style
- General Methods of formatting and Subtractin...
- .NET LinkButton web control

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 1 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials