DB2ParameterCollection.Contains Method
Gets a value indicating whether a DB2Parameter object exists in the collection.
Overload list
Name | Description |
---|---|
Contains(Object) As Boolean Implements IList.Contains | Gets a value indicating whether a DB2®Parameter object exists in the collection. |
Contains(String) As Boolean Implements IDataParameterCollection.Contains | Gets a value indicating whether a DB2Parameter object with the specified parameter name exists in the collection. |
Example
[Visual Basic, C#] The following example searches for a DB2Parameter with a given DB2Parameter.ParameterName 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 a DB2ParameterCollection has already been created.
Note: [Visual Basic, C#] This example shows how to use one of the overloaded versions of Contains. 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());
}