System.Data Namespace DataRelationCollection Class
Returns the DataRelation at the specified index in the collection.
DataRelation variable = DataRelationCollection.Item [ index ];
... or ...
DataRelation variable = DataRelationCollection [ index ];
dim variable as DataRelation = DataRelationCollection.Item ( index )
... or ...
dim variable as DataRelation = DataRelationCollection ( index )
variable : DataRelation = DataRelationCollection.Item ( index );
... or ...
variable : DataRelation = DataRelationCollection ( index ); |
|
C# |
VB |
JScript |
- index
- The zero-based index of the relation to return.
The DataRelation at the specified index.
Exception Type |
Condition |
IndexOutOfRangeException |
Occurs when the index value is greater than the number of items in the collection. |
If the specified index does not exist, an exception is thrown.
The following example uses the Item property to print the names of all DataRelation objects in the collection, each specified by index.
private void PrintRelationNamesByIndex ( DataSet ds ) {
// get the DataRelationCollection from a DataSet.
DataRelationCollection relations = ds.Relations;
// print each relation's name using the index.
for ( int i = 0; i < relations.Count; i++ ) {
Response.Write ( relations [ ] );
}
}
Private Sub PrintRelationNamesByIndex ( Dim ds As DataSet )
' get the DataRelationCollection from a a DataSet.
Dim relations As DataRelationCollection = ds.Relations
' print each relation's name using the index.
For i = 0 To relations.Count -1
Response.Write ( relations ( i ) )
Next
End Sub |
|
C# |
VB |
DataRelationCollection Members DataRelationCollection.Item Overload List DataRelation