将从数据库中查询的数据,转换成XML格式
string connStr = "Server=178.88.1.121;initial catalog=test;User=sa;password=abc.DB";
using (SqlConnection conn = new SqlConnection(connStr))
{
SqlCommand command = new SqlCommand("select top 4 * from h_emp_mstr", conn);
conn.Open();
DataSet ds = new DataSet();
ds.DataSetName = "employeelist";
ds.Load(command.ExecuteReader(), LoadOption.OverwriteChanges, "employee");
Response.ContentType = "text/xml";
ds.WriteXml(Response.OutputStream);
}