DataRow.Table 屬性

定義

取得其中的這個資料列具有結構描述的 DataTableGets the DataTable for which this row has a 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

屬性值

這個資料列所屬的 DataTableThe DataTable to which this row belongs.

範例

下列範例會使用 Table 屬性來傳回 DataTable之 columns 集合的參考。The following example uses the Table property to return a reference to the columns collection of the 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

備註

DataRow 不一定屬於任何資料表的資料列集合。A DataRow does not necessarily belong to any table's collection of rows. DataRow 已建立但未新增至 DataRowCollection時,就會發生這種行為。This behavior occurs when the DataRow has been created but not added to the DataRowCollection. 如果 RowState 屬性傳回 DataRowState.Detached,則該資料列不在任何集合中。If the RowState property returns DataRowState.Detached, the row is not in any collection.

適用於

另請參閱