【发布时间】:2013-03-10 02:34:29
【问题描述】:
我正在使用(对于 XML 自动从 sql server 检索所有表数据。 XSLT 为来自服务器的 XML 设置样式。 我想将从 sql server 返回的 xml 保存到文件夹内的 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;
}
}
非常感谢您的帮助
【问题讨论】:
-
您是指以编程方式创建的文件夹,而不是有问题的文件夹吗?我知道有时对我来说是一样的! :)
标签: c# sql sql-server xml