DB2ParameterCollection.Contains (Object) Method
Gets a value indicating whether a DB2Parameter object exists in the collection.
- Namespace:
IBM.Data.DB2
- Assembly:
IBM.Data.DB2
(inIBM.Data.DB2.dll
)
Syntax
[Visual Basic]
NotOverridable Overloads Public Function Contains( _
ByVal value As Object _
) As Boolean Implements IList.Contains
[C#]
public bool Contains(
object value
);
[C++]
public: __sealed bool Contains(
Object* value
);
[JScript]
public function Contains(
value : Object
) : Boolean;
- Implements:
- IList.Contains
Parameters
- value
- The value of the DB2®Parameter object to find.
Return value
true
if
the collection contains the DB2Parameter ; otherwise, false
.
Exceptions
Exception type | Condition |
---|---|
ArgumentNullException | The value parameter is null. |
InvalidCastException | The value parameter was not a DB2Parameter . |
Example
[Visual Basic, C#] The following example searches for a DB2Parameter within 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 a 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());
}