DB2ParameterCollection.IndexOf Method
Gets the location in the collection of the DB2Parameter.
Overload list
Name | Description |
---|---|
IndexOf(Object) As Integer Implements IList.IndexOf | Gets the location in the collection of the DB2®Parameter object with the specified parameter name. |
IndexOf(String) As Integer Implements IDataParameterCollection.IndexOf | Gets the location in the collection of the DB2Parameter with a specific parameter name. |
Example
[Visual Basic, C#] The following example searches for a DB2Parameter with a given DB2Parameter.Name within a DB2ParameterCollection. If the parameter exists, the example displays the name and index of the parameter. If the parameter does not exist, the example displays an error. This example assumes that an DB2ParameterCollection collection has already been created.
Note: [Visual Basic, C#] This example shows how to use one of the overloaded versions of IndexOf. For other examples that might be available, see
the individual overload topics.
[Visual Basic]
Public Sub SearchDB2Params()
' ...
' create DB2ParameterCollection myParameters
' ...
If Not myParameters.Contains("Description") Then
MessageBox.Show("ERROR: no such parameter in the collection")
Else
MessageBox.Show("Name: " & myParameters("Description").ToString() & _
"Index: " & myParameters.IndexOf("Description").ToString())
End If
End Sub 'SearchDB2Params
[C#]
public void SearchDB2Params() {
// ...
// create DB2ParameterCollection myParameters
// ...
if (!myParameters.Contains("Description"))
MessageBox.Show("ERROR: no such parameter in the collection");
else
MessageBox.Show("Name: " + myParameters["Description"].ToString() +
"Index: " + myParameters.IndexOf("Description").ToString());
}