本文整理汇总了C#中System.Xml.XmlDataDocument.CloneNode方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDataDocument.CloneNode方法的具体用法?C# XmlDataDocument.CloneNode怎么用?C# XmlDataDocument.CloneNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了XmlDataDocument.CloneNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Data;
using System.Xml;
using System.Data.SqlClient;
public class Sample
{
public static void Main()
{
DataSet dsNorthwind = new DataSet();
//Create the connection string.
String sConnect;
sConnect="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind";
//Create a connection object to connect to the northwind db.
SqlConnection nwconnect = new SqlConnection(sConnect);
//Create a command string to select all the customers in the WA region.
String sCommand = "Select * from Customers where Region='WA'";
//Create an adapter to load the DataSet.
SqlDataAdapter myDataAdapter = new SqlDataAdapter(sCommand, nwconnect);
//Fill the DataSet with the selected records.
myDataAdapter.Fill(dsNorthwind,"Customers");
//Load the document with the DataSet.
XmlDataDocument doc = new XmlDataDocument(dsNorthwind);
//Create a shallow clone of the XmlDataDocument. Note that although
//none of the child nodes were copied over, the cloned node does
//have the schema information.
XmlDataDocument clone = (XmlDataDocument) doc.CloneNode(false);
Console.WriteLine("Child count: {0}", clone.ChildNodes.Count);
Console.WriteLine(clone.DataSet.GetXmlSchema());
}
}