DB2ParameterCollection.IndexOf Method (Object)

Gets the location in the collection of the DB2Parameter object with the specified parameter name.

Namespace:
IBM.Data.DB2
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Syntax


[Visual Basic]
NotOverridable Overloads Public Function IndexOf( _
   ByVal value As Object _
) As Integer Implements IList.IndexOf
[C#]
public int IndexOf(
   object value
);
[C++]
public: __sealed int IndexOf(
   Object* value
);
[JScript]
public function IndexOf(
   value : Object
) : int;
Implements:
IList.IndexOf

Parameters

value
The DB2®Parameter object to find.

Return value

The zero-based location of the DB2Parameter in the collection.

Exceptions

Exception type Condition
InvalidCastException The value parameter is not a DB2Parameter .

Example

[Visual Basic, C#] The following example searches for a DB2Parameter object in a DB2ParameterCollection . If the parameter exists, the example displays the index of the parameter. If the parameter does not exist, the example displays an error. This example assumes that an DB2ParameterCollection has already been created.

[Visual Basic]
Public Sub SearchDB2Params()
    ' ...
    ' create DB2ParameterCollection myParameters and DB2Parameter myNewParam
    ' ...
    If Not myParameters.Contains(CType(myNewParam, Object)) Then
        MessageBox.Show("ERROR: no such parameter in the collection")
    Else
        MessageBox.Show("match on parameter #" & myParameters.IndexOf(CType(myNewParam, Object)).ToString())
    End If
End Sub 'SearchDB2Params

[C#]
public void SearchDB2Params() {
    // ...
    // create DB2ParameterCollection myParameters and DB2Parameter myNewParam
    // ...
    if (!myParameters.Contains((Object) myNewParam))
       MessageBox.Show("ERROR: no such parameter in the collection");
    else
       MessageBox.Show("match on parameter #" +
                 myParameters.IndexOf((Object) myNewParam).ToString());
}