This documentation is archived and is not being maintained.

DataSet.Tables Property

Gets the collection of tables contained in the DataSet.

[Visual Basic]
Public ReadOnly Property Tables As DataTableCollection
public DataTableCollection Tables {get;}
public: __property DataTableCollection* get_Tables();
public function get Tables() : DataTableCollection;

Property Value

The DataTableCollection contained by this DataSet; otherwise a null value if no DataTable objects exist.


To add tables to the collection, use Add method of the DataTableCollection. To remove tables, use the Remove method.


[Visual Basic, C#, C++] The following example returns the DataSet object's DataTableCollection, and prints the columns and rows in each table.

[Visual Basic] 
Private Sub PrintRows(ByVal myDataSet As DataSet)
   Dim myTable As DataTable
   Dim myRow As DataRow
   Dim myColumn As DataColumn
   ' For each table in the DataSet, print the row values.
   For Each myTable in myDataSet.Tables
      For Each myRow In myTable.Rows
         For Each myColumn in myTable.Columns
         Next myColumn
      Next myRow
   Next myTable
End Sub

private void PrintRows(DataSet myDataSet){
   // For each table in the DataSet, print the row values.
   foreach(DataTable myTable in myDataSet.Tables){
      foreach(DataRow myRow in myTable.Rows){
         foreach (DataColumn myColumn in myTable.Columns){

 void PrintRows(DataSet* myDataSet){
    // For each table in the DataSet, print the row values.
    System::Collections::IEnumerator* myEnum = myDataSet->Tables->GetEnumerator();
    while (myEnum->MoveNext())
       DataTable* myTable = __try_cast<DataTable*>(myEnum->Current);
       System::Collections::IEnumerator* myEnum1 = myTable->Rows->GetEnumerator();
       while (myEnum1->MoveNext())
          DataRow* myRow = __try_cast<DataRow*>(myEnum1->Current);
          System::Collections::IEnumerator* myEnum2 = myTable->Columns->GetEnumerator();
          while (myEnum2->MoveNext())
             DataColumn* myColumn = __try_cast<DataColumn*>(myEnum2->Current);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataSet Class | DataSet Members | System.Data Namespace | DataTable | DataTableCollection