using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Xml;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Text;

public partial class Default5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("select id,test_time,title,author from test", conn);
DataSet ds = new DataSet();
try
{
da.Fill(ds, "test");
FileStream fs = new FileStream(@"d:\temp\test1.xml",FileMode.Create);
XmlWriterSettings setting = new XmlWriterSettings();
setting.Encoding = Encoding.Unicode;
XmlWriter xw = XmlWriter.Create(fs, setting);
xw.WriteProcessingInstruction("xml", "version='1.0'");
ds.WriteXml(xw);

xw.Close();
fs.Close();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
throw;
}
finally
{
Response.Write("輸出成功");
}
}
}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 ylw1125 的頭像
    ylw1125

    程式搜集分享精靈

    ylw1125 發表在 痞客邦 留言(0) 人氣()