<%@ Page Language="C#" Debug="true" %> <%@ Import Namespace="System.Data"%> <%@ Import Namespace="System.Data.OleDb"%> <script runat="server"> void Page_Load(object sender, EventArgs e) { OleDbConnection objConn = new OleDbConnection(); OleDbCommand objCmd = new OleDbCommand(); OleDbDataAdapter dtAdapter = new OleDbDataAdapter(); DataSet ds = new DataSet(); String strConnString,strSQL; strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("database/mydatabase.mdb") + ";"; strSQL = "SELECT * FROM customer"; objConn.ConnectionString = strConnString; objCmd.Connection = objConn; objCmd.CommandText = strSQL; objCmd.CommandType = CommandType.Text; dtAdapter.SelectCommand = objCmd; dtAdapter.Fill(ds); dtAdapter = null; objConn.Close(); objConn = null; //*** Export XML ***// ds.Tables[0].WriteXml(Server.MapPath("XML/myXml.xml")); //ds.Tables[0].WriteXmlSchema(Server.MapPath("XML/myXml.xml")); ds = null; this.lblText.Text = "XML Created <a href=XML/myXml.xml>click here</a> to view"; } </script> <html> <head> <title>ThaiCreate.Com ASP.NET - XML</title> </head> <body> <form id="form1" runat="server"> <asp:Label id="lblText" runat="server"></asp:Label> </form> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท