www.google.co.in

Saturday, March 28, 2009

XML files from SQL Database

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

1 comment: