我正在使用(對於XML自動檢索來自sql server的所有表數據 XSLT從服務器中對XML進行樣式設置 我想保存從服務器返回的XML SQL Server以XML文件的文件夾內(創建有問題以及XML文件夾)將從SQL服務器返回的XML保存到xml文件中
protected void Page_Load(object sender, EventArgs e)
{
string strConnenction = System.Configuration.ConfigurationManager.
ConnectionStrings["Connectionstring0034"].ConnectionString;
XmlDocument xd = new XmlDocument();
XPathNavigator xpathnav = xd.CreateNavigator();
using (SqlConnection conn = new SqlConnection(strConnenction))
{
conn.Open();
SqlCommand command = new SqlCommand(
"select * from Employees as products for XML AUTO, ELEMENTS", conn);
using (XmlWriter xw = xpathnav.PrependChild())
{
xw.WriteStartElement("products");
using (XmlReader xr = command.ExecuteXmlReader())
{
xw.WriteNode(xr, true);
}
xw.WriteEndElement();
}
}
XmlProducts.XPathNavigator = xpathnav;
}
}
感謝你這麼多的幫助
您的意思是文件夾創建編程,而不是有問題?我知道我有時也是一樣的! :) – 2013-03-10 21:44:03