我正在使用(对于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