Recent Posts

ASP.NET: Tạo ra các file XML từ Cơ sở dữ liệu SQL

-

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

Sub Page_Load(Source as Object, E as EventArgs)
Dim strCon as string = "Server=127.0.0.1;uid=sa;pwd=123;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 conn as SQLConnection
Dim objAdapter as SQLDataAdapter

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

objAdapter.Fill(objDataSet, "Empls")

objDataSet.WriteXml(Server.MapPath("xml_file.xml"))
lbl_hienthi.text = "<a href=xml_file.xml>Check your XML file</a>"
End sub

</script>
<html>
<head>
<title>Generating XML files from SQL Database</title>
</head>
<body>
<asp:label id="lbl_hienthi" runat="server" />
</body>
</html>




Klik untuk melihat kode: :) =( :s :D :-D ^:D ^o^ 7:( :Q :p T_T @@, :-a :W *fck* x@