做项目的时候ext需要xml数据,顺手就用asp.net 导了个,如下:
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection sc=new SqlConnection("server=localhost;database=northwind;user id=sa;password=");
sc.Open();
SqlCommand scd=new SqlCommand("SELECT ProductID, ProductName FROM Products WHERE CategoryID = 1 ORDER BY ProductID",sc);
SqlDataAdapter sda=new SqlDataAdapter(scd);
DataSet ds=new DataSet();
sda.Fill(ds,"product");
sc.Close();
MemoryStream ms=new MemoryStream();
ds.WriteXml(ms,XmlWriteMode.IgnoreSchema);
ms.Position=0;
StreamReader sr=new StreamReader(ms);
Page.Response.Write(sr.ReadToEnd());
sr.Close();
}