DataRow.Table 屬性

定義

取得其中的這個資料列具有結構描述的 DataTable

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

屬性值

這個資料列所屬的 DataTable

範例

下列範例使用 Table 屬性傳回 的數據行集合 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不一定屬於任何數據表的數據列集合。 建立 但未加入 至 DataRowCollectionDataRow,就會發生此行為。 RowState如果屬性傳DataRowState.Detached回 ,則數據列不在任何集合中。

適用於

另請參閱