Generating XML files and Write the Deatils from DataBase in XML file

Posted by Chikul under ASP.NET category on | Views : 1542
It will generate Nodes & Child nodes based on the DataBase Column Names and write in the XML file

<?xml version="1.0" standalone="yes" ?>
- <NewDataSet>
- <Empls>
<Name>App. Panda</Name>
- <Empls>

Codes :

Imports System.Data
Imports System.Data.SqlClient

Partial Class Default3
Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
'Generating XML files and Write the Deatils from DataBase in XML file
Dim strCon As String = "Password=wizardpass;Persist Security Info=True;User ID=wizard;Initial Catalog=Testing;Data Source=IBM\SQL2005" '"Server=;uid=sa;pwd=;Database=Northwind;"
Dim strSQL As String = "Select Id,Name,MiddleName,LastName,ManagerId,Salary,Status from Employee order by Id desc"
Dim objDataSet As New DataSet()
Dim objCon As SQLConnection
Dim objAdapter As SQLDataAdapter

objCon = New SQLConnection(strCon)
objAdapter = New SQLDataAdapter(strSQL, objCon)

objAdapter.Fill(objDataSet, "Empls")

Response.Write("<a href=employee_xml_file.xml>Check your XML file</a>")
End Sub
End Class

Comments or Responses

Login to post response