if you want to output dataset as is, tryDataSet1.WriteXml(Response.OutputStream);
otherwise, you need to create Xml in the way you want, then use Response.Write()
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script language="C#" runat="server">
void Page_Load(object sender, EventArgs e)
{
SqlDataAdapter da = new SqlDataAdapter("select * from authors",
"server=localhost;database=pubs;uid=sa;pwd=;"); DataSet ds = new DataSet();
da.Fill(ds); Response.Clear();
Response.ContentType="text/xml";
Response.AddHeader("Content-Disposition", "attachment; filename=TestXml.xml");
ds.WriteXml(Response.OutputStream);
Response.End();
}
</script>
otherwise, you need to create Xml in the way you want, then use Response.Write()
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script language="C#" runat="server">
void Page_Load(object sender, EventArgs e)
{
SqlDataAdapter da = new SqlDataAdapter("select * from authors",
"server=localhost;database=pubs;uid=sa;pwd=;"); DataSet ds = new DataSet();
da.Fill(ds); Response.Clear();
Response.ContentType="text/xml";
Response.AddHeader("Content-Disposition", "attachment; filename=TestXml.xml");
ds.WriteXml(Response.OutputStream);
Response.End();
}
</script>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货