다음을 통해 공유


XmlDataDocument 생성자

정의

XmlDataDocument 클래스의 새 인스턴스를 초기화합니다.

오버로드

XmlDataDocument()

XmlDataDocument 클래스의 새 인스턴스를 초기화합니다.

XmlDataDocument(DataSet)

지정된 XmlDataDocument를 사용하여 DataSet 클래스의 새 인스턴스를 초기화합니다.

XmlDataDocument()

XmlDataDocument 클래스의 새 인스턴스를 초기화합니다.

public:
 XmlDataDocument();
public XmlDataDocument ();
Public Sub New ()

설명

DataSet 항목이 만들어지고 .와 연결됩니다 XmlDataDocument.

적용 대상

XmlDataDocument(DataSet)

지정된 XmlDataDocument를 사용하여 DataSet 클래스의 새 인스턴스를 초기화합니다.

public:
 XmlDataDocument(System::Data::DataSet ^ dataset);
public XmlDataDocument (System.Data.DataSet dataset);
new System.Xml.XmlDataDocument : System.Data.DataSet -> System.Xml.XmlDataDocument
Public Sub New (dataset As DataSet)

매개 변수

dataset
DataSet

DataSet에 로드할 XmlDataDocument입니다.

예제

다음 예제에서는 고객 테이블을 .에 로드합니다 XmlDataDocument.

이 예제에서는 SQL Server 2000 Northwind 데이터베이스를 사용합니다.

#using <System.Xml.dll>
#using <System.Transactions.dll>
#using <System.EnterpriseServices.dll>
#using <System.dll>
#using <System.Data.dll>

using namespace System;
using namespace System::Data;
using namespace System::Xml;
using namespace System::Data::SqlClient;
int main()
{
   DataSet^ dsNorthwind = gcnew 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 = gcnew 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 = gcnew SqlDataAdapter( sCommand,nwconnect );
   
   //Fill the DataSet with the selected records.
   myDataAdapter->Fill( dsNorthwind, "Customers" );
   
   //Load the document with the DataSet.
   XmlDataDocument^ doc = gcnew XmlDataDocument( dsNorthwind );
   
   //Display the XmlDataDocument.
   doc->Save( Console::Out );
}
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);

     //Display the XmlDataDocument.
     doc.Save(Console.Out);
  }
}
Imports System.Xml
Imports System.Data
Imports System.Data.SqlClient

public class Sample
 
  public shared sub Main()
   
    Dim dsNorthwind as DataSet = new DataSet()
 
    'Create the connection string.
    Dim sConnect as String           
    sConnect="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind"     
          
    'Create a connection object to connect to the northwind db.
    Dim nwconnect as SqlConnection
    nwconnect = new SqlConnection(sConnect)
 
    'Create a command string to select all the customers in the WA region.
    Dim sCommand as String = "Select * from Customers where Region='WA'"
 
    'Create an Adapter to load the DataSet.
    Dim myDataAdapter as SqlDataAdapter
    myDataAdapter = new SqlDataAdapter(sCommand, nwconnect)
 
    'Fill the DataSet with the selected records.
    myDataAdapter.Fill(dsNorthwind, "Customers")
 
    'Load the document with the DataSet.
    Dim doc as XmlDataDocument = new XmlDataDocument(dsNorthwind)  
 
    'Display the XmlDataDocument.
    doc.Save(Console.Out)
 
  end sub
end class

설명

지정된 XmlDataDocument .와 동기화됩니다 DataSet. 의 모든 데이터는 .를 DataSet 통해 XmlDataDocument즉시 사용할 수 있습니다. 의 DataSet 모든 변경 내용은 .에 XmlDataDocument전파됩니다. 스키마와 XmlDataDocument일치하는 DataSet 경우 변경된 내용은 .에 DataSet전파됩니다.

추가 정보

적용 대상