System.Data Namespace DataSet Class
Returns the collection of tables contained in the DataSet.
Script |
[ DataTableCollection variable = ] DataSet.Tables |
The property is read only with no default value.
To add tables to the collection, use Add method of the DataTableCollection. To remove tables, use the Remove method.
The following example returns the DataSet object's DataTableCollection, and prints the columns and rows in each table.
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 ) {
Response.Write ( myRow [ myColumn ] );
}
}
}
}
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
Response.Write ( myRow ( myColumn ) )
Next myColumn
Next myRow
Next myTable
End Sub |
|
C# |
VB |
DataSet Members DataTable DataTableCollection