刚刚接触ASP,写了下面一段代码想要将dataset中的数据转成XML,不知道为什么,转换之后的txt文件不仅仅有dataset里面的信息,还有网页的HTML信息,求助!!!
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(ConnectionString);
SqlCommand command = new SqlCommand("select * from Depart", conn);
conn.Open();
DataSet ds = new DataSet();
ds.DataSetName = "Department";
ds.Load(command.ExecuteReader(), LoadOption.OverwriteChanges, "Department");
ds.WriteXml(Response.OutputStream);
Response.AddHeader("content-disposition",
"attachment;filename=depart.txt");
Response.Charset = "GB2312";
Response.ContentType = "text/xml";
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(ConnectionString);
SqlCommand command = new SqlCommand("select * from Depart", conn);
conn.Open();
DataSet ds = new DataSet();
ds.DataSetName = "Department";
ds.Load(command.ExecuteReader(), LoadOption.OverwriteChanges, "Department");
ds.WriteXml(Response.OutputStream);
Response.AddHeader("content-disposition",
"attachment;filename=depart.txt");
Response.Charset = "GB2312";
Response.ContentType = "text/xml";
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货