次の方法で共有


DataRow.Table プロパティ

この行のスキーマが関連する DataTable を取得します。

Public ReadOnly Property Table As DataTable
[C#]
public DataTable Table {get;}
[C++]
public: __property DataTable* get_Table();
[JScript]
public function get Table() : DataTable;

プロパティ値

この行が属する DataTable

解説

メモ    DataRow が必ずしもテーブルの行コレクションに属しているとは限りません。これは、 DataRow が作成されていても DataRowCollection に追加されていない場合に発生します。 RowState プロパティが DataRowState.Detached を返した場合、この行はどのコレクションにも属していません。

使用例

[Visual Basic, C#, C++] Table プロパティを使用して、 DataTable の列コレクションに参照を返す例を次に示します。

 
Private Sub GetTable(ByVal myRow As DataRow)
   ' Get the DataTable of a DataRow
   Dim myTable As DataTable = myRow.Table
   ' Print the DataType of each column in the table.
   Dim dc As DataColumn
   For Each dc in myTable.Columns
      Console.WriteLine(dc.DataType)
   Next
End Sub

[C#] 
private void GetTable(DataRow myRow){
   // Get the DataTable of a DataRow
   DataTable myTable = myRow.Table;
   // Print the DataType of each column in the table.
   foreach(DataColumn dc in myTable.Columns){
      Console.WriteLine(dc.DataType);
   }
}

[C++] 
private:
 void GetTable(DataRow* myRow){
    // Get the DataTable of a DataRow
    DataTable* myTable = myRow->Table;
    // Print the DataType of each column in the table.
    System::Collections::IEnumerator* myEnum = myTable->Columns->GetEnumerator();
    while (myEnum->MoveNext())
    {
       DataColumn* dc = __try_cast<DataColumn*>(myEnum->Current);
       Console::WriteLine(dc->DataType);
    }
 }

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

DataRow クラス | DataRow メンバ | System.Data 名前空間 | DataColumnCollection | DataTable