Generating XML files from SQL Database

<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.XML" %>
<%@ Import Namespace="System.Data.SQLClient" %>

Sub Page_Load(Source as Object, E as EventArgs)
Dim strCon as string = "Server=127.0.0.1;uid=sa;pwd=;Database=Northwind;"
Dim strSQL as string = "Select EmployeeID, FirstName, LastName, Address, City, PostalCode, Country from Employees
order by EmployeeID 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")

objDataSet.WriteXml(Server.MapPath("emp_xml_file.xml"))
message.text = "Check your XML file"

end sub

No comments:

Post a Comment