web 2.0

ASP.NET(vb.net) & Generating XML From DataSet

ASP.NET(vb.net) & Generating XML From DataSet - The in this article we will show example scripts ASP.NET how to Generating XML from DataSet.

ShotDev Focus:
- ASP.NET(vb.net) & Generating XML From DataSet

Example

AspNetXmlFromDataSet.aspx

<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.OleDb"%>
<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)

Dim objConn As New OleDbConnection
Dim objCmd As New OleDbCommand
Dim dtAdapter As New OleDbDataAdapter

Dim ds As New DataSet
Dim strConnString,strSQL As String

strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("database/mydatabase.mdb")&";"
strSQL = "SELECT * FROM customer"

objConn.ConnectionString = strConnString
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd

dtAdapter.Fill(ds)

dtAdapter = Nothing
objConn.Close()
objConn = Nothing

'*** Export XML ***'
ds.Tables(0).WriteXML(Server.MapPath("XML/myXml.xml"))
'ds.Tables(0).WriteXmlSchema(Server.MapPath("XML/myXml.xml"))
ds = Nothing

Me.lblText.Text = "XML Created <a href=XML/myXml.xml>click here</a> to view"
End Sub
</script>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label id="lblText" runat="server"></asp:Label>
</form>
</body>
</html>

Screenshot

ASP.NET(vb.net) & Generating XML From DataSet
.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.