XmlDataDocument.GetElementFromRow(DataRow) Yöntem

Tanım

XmlElement Belirtilen DataRowile ilişkili öğesini alır.

C#
public System.Xml.XmlElement GetElementFromRow (System.Data.DataRow r);

Parametreler

r
DataRow

İlişkilisini DataRowXmlElement almak istediğiniz.

Döndürülenler

XmlElement Belirtilen DataRowöğesinin bir gösterimini içeren .

Örnekler

Aşağıdaki örnek içine a DataSetXmlDataDocument yükler ve ardından ilk müşteri kaydını temsil eden bir XmlElement oluşturur.

Örnekte SQL Server 2000 Northwind veritabanı kullanılır.

C#
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);
  }
}

Şunlara uygulanır

Ürün Sürümler
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Ayrıca bkz.