System.Data Namespace DataTableCollection Class
Returns the DataTable at the specified index.
DataTable variable = DataTableCollection.Item [ index ];
... or ...
DataTable variable = DataTableCollection [ index ];
dim variable as DataTable = DataTableCollection.Item ( index )
... or ...
dim variable as DataTable = DataTableCollection ( index )
variable : DataTable = DataTableCollection.Item ( index );
... or ...
variable : DataTable = DataTableCollection ( index ); |
|
C# |
VB |
JScript |
- index
- The index of the DataTable to find.
A DataTable at the specified index.
Exception Type |
Condition |
IndexOutOfRangeException |
Occurs when the index value is greater than the number of items in the collection. |
Use the Contains method to determine if a table with a specific name exists. If you have the name of a table, but not its index, use the IndexOf method to return the index.
The following example retrieves a DataTable by its index.
private void GetDataTableByIndex ( DataSet ds ) {
// get the DataTableCollection.
DataTableCollection myTables = ds.Tables;
// iterate through the collection to get each table index.
for ( int i = 0; i < myTables.Count; i++ ) {
Response.Write ( myTables [ ].TableName );
}
}
Private Sub GetDataTableByIndex ( ByVal ds As DataSet )
' get the DataTableCollection.
Dim myTables As DataTableCollection = ds.Tables
' iterate through the collection to get each table index.
Dim i As Integer
For i = 0 To myTables.Count - 1
Response.Write ( myTables ( i ).TableName )
Next
End Sub |
|
C# |
VB |
DataTableCollection Members DataTableCollection.Item Overload List