DataRow.Table Egenskap

Definition

Hämtar för vilken den DataTable här raden har ett schema.

public:
 property System::Data::DataTable ^ Table { System::Data::DataTable ^ get(); };
public System.Data.DataTable Table { get; }
member this.Table : System.Data.DataTable
Public ReadOnly Property Table As DataTable

Egenskapsvärde

Den DataTable rad som den här raden tillhör.

Exempel

I följande exempel används Table egenskapen för att returnera en referens till kolumnsamlingen för DataTable.

private void GetTable(DataRow row)
{
    // Get the DataTable of a DataRow
    DataTable table = row.Table;

    // Print the DataType of each column in the table.
    foreach(DataColumn column in table.Columns)
    {
        Console.WriteLine(column.DataType);
    }
}
Private Sub GetTable(ByVal row As DataRow)
   ' Get the DataTable of a DataRow
   Dim table As DataTable = row.Table

   ' Print the DataType of each column in the table.
   Dim column As DataColumn
   For Each column in table.Columns
      Console.WriteLine(column.DataType)
   Next
End Sub

Kommentarer

A DataRow tillhör inte nödvändigtvis någon tabells samling rader. Det här beteendet inträffar när DataRow har skapats men inte lagts till i DataRowCollection. Om egenskapen RowState returnerar DataRowState.Detachedfinns raden inte i någon samling.

Gäller för

Se även