XmlDataDocument.GetElementFromRow(DataRow) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 XmlElement와 관련된 DataRow를 검색합니다.
public:
System::Xml::XmlElement ^ GetElementFromRow(System::Data::DataRow ^ r);
public System.Xml.XmlElement GetElementFromRow (System.Data.DataRow r);
member this.GetElementFromRow : System.Data.DataRow -> System.Xml.XmlElement
Public Function GetElementFromRow (r As DataRow) As XmlElement
매개 변수
- r
- DataRow
검색할 관련 DataRow
가 있는 XmlElement
입니다.
반환
지정된 XmlElement
의 표현이 포함된 DataRow
입니다.
예제
다음 예제에서는 a를 DataSet
XmlDataDocument
로드한 다음 첫 번째 고객 레코드를 나타내는 값을 만듭니다 XmlElement
.
이 예제에서는 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 );
//Create an element representing the first customer record.
DataRow^ row = doc->DataSet->Tables[ 0 ]->Rows[ 0 ];
XmlElement^ elem = doc->GetElementFromRow( row );
Console::WriteLine( elem->OuterXml );
}
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 an element representing the first customer record.
DataRow row = doc.DataSet.Tables[0].Rows[0];
XmlElement elem = doc.GetElementFromRow(row);
Console.WriteLine(elem.OuterXml);
}
}
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)
'Create an element representing the first customer record.
Dim row as DataRow = doc.DataSet.Tables.Item(0).Rows.Item(0)
Dim elem as XmlElement = doc.GetElementFromRow(row)
Console.WriteLine(elem.OuterXml)
end sub
end class