用XML编写SQL查询 [英] Writing SQL queries in XML
本文介绍了用XML编写SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<queries>
<sql>
Update tblCustomerMst Set CUstomerName = 'xxx' Where CustID = 12
Update tblCustomerMst Set CUstomerName = 'yyy' Where CustID = 13
</sql>
</queries>
这些Xml文件是使用.Net
生成的
如何在sql2000中执行此Xml文件
请给我完整的信息
请帮助我
在此先感谢
These Xml file is generated using .Net
How to Execute this Xml file in sql2000
Please give me Full information
Pls help me
Thanks In Advance
推荐答案
您可以从以下代码开始.它不是满足您要求的完整解决方案,但希望它能帮助您开始.
You may start with below code. It is not the complete solution for your requirement, but I hope it will help you to start with.
string xmlString = "YourXML";
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(xmlString);
System.Xml.XmlNodeList nodeList;
System.Xml.XmlNode root = doc.DocumentElement;
nodeList= root.SelectNodes("queries/sql");
string query = string.Empty;
foreach (System.Xml.XmlNode Query in nodeList)
{
query= Query.InnerText;
//Execute your Query using Ado.Net Here.
//Make sure you have semi-colon(;) after each SQL Query/Command.
}
看看下面的链接,使用Ado.Net执行您的SQL查询.
SqlCommand.ExecuteNonQuery方法
Have a look at below link to execute your SQL queries using Ado.Net.
SqlCommand.ExecuteNonQuery Method
这篇关于用XML编写SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文