C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ASP.NET WebForms »

create Dynamic XML file using Data from a SQL Database Table


Posted Date: 03 Jul 2009    Resource Type: Code Snippets    Category: ASP.NET WebForms
Author: UltimateRenganMember Level: Diamond    
Rating: 1 out of 5Points: 5



1)Select the table values from database
2)bind the values to Dataset
3)dataset to xmlDataDocument
4)Give the xml filename and save to current location.

Imports System.Data
Imports System.Data.SqlClient
Imports System.Xml

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strConn As String
'create connection to database table.
strConn = "USER=asd;PASSWORD=45646;SERVER=qwer;DATABASE=Emp"
Dim MySQL As String = "Select empno, empname from kk"
Dim MyConn As New SqlClient.SqlConnection(strConn)
Dim ds As DataSet = New DataSet()
Dim Cmd As New SqlClient.SqlDataAdapter(MySQL, MyConn)
'Fill the Table values to Dataset
Cmd.Fill(ds, "Emptbl")
'Bind the dataset values to xmldatadocument
Dim doc As New XmlDataDocument(ds)
doc.Save(MapPath("NewXMLName.xml"))
'This is where we are saving the data in an XML file NewXMLName.xml
End Sub
End Class


The output look like

< NewDataSet >
< Emptbl>
< empno>3< /empno>
< empname>777
< /Emptbl>
< Emptbl>
< empno>344< /empno>
< empname>rrr677 < /empname>
< /Emptbl>
< Emptbl>
< empno>3< /empno>
< empname>ggg'D < /empname>
< /Emptbl>
< Emptbl>
< empno>4< /empno>
< empname>d < /empname>
< /Emptbl>
< Emptbl>
< /Emptbl>
< /NewDataSet>



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Create Dynamic XML file using SQL  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to add Sitemap to Treeview control
Previous Resource: How to use Query string in asp.net
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET WebForms


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use