通过


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

注解

A DataRow 不一定属于任何表的行集合。 创建但未添加到该对象DataRowCollectionDataRow,会发生此行为。 RowState如果属性返回DataRowState.Detached,则行不在任何集合中。

适用于

另请参阅