JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Looping over all Tables in a Dataset

In the previous topic, we looped over all the rows and columns in the authors table in the pubs database. But what if you wanted to loop over all the tables in a dataset as well? You can access the tables in a dataset with its Tables property, so here's how to display all the data in an entire dataset, table-by-table, row-by-row, and column-by-column:

For Each CurrentTable in DataSet11.Tables
    For Each CurrentRow In CurrentTable.Rows
        For Each CurrentColumn In CurrentTable.Columns
            TextBox1.Text &= CurrentRow(CurrentColumn) & ControlChars.Tab _
                & ControlChars.Tab
            Next CurrentColumn
        TextBox1.Text &= ControlChars.CrLf
    Next CurrentRow
Next CurrentTable
Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor