DB2ParameterCollection.IndexOf Method (String)
Gets the location in the collection of the DB2Parameter with a specific parameter name.
- Namespace:
IBM.Data.DB2
- Assembly:
IBM.Data.DB2
(inIBM.Data.DB2.dll
)
Syntax
[Visual Basic]
NotOverridable Overloads Public Function IndexOf( _
ByVal parameterName As String _
) As Integer Implements IDataParameterCollection.IndexOf
[C#]
public int IndexOf(
string parameterName
);
[C++]
public: __sealed int IndexOf(
String* parameterName
);
[JScript]
public function IndexOf(
parameterName : String
) : int;
- Implements:
- IDataParameterCollection.IndexOf
Parameters
- parameterName
- The name of the parameter to retrieve.
Return value
The zero-based location of the DB2®Parameter in the collection.
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.
[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());
}