System.Data.SqlClient Namespace SqlParameterCollection Class
Checks whether a given SqlParameter object is in the collection.
[ VB ]
Overloads Public Function Contains ( _
ByVal value As Object _
) As Boolean
[ C# ]
public bool Contains (
object value
);
[ C++ ]
public: bool Contains (
Object* value
);
[ JScript ]
public function Contains (
value : Object
) : Boolean
- value
- The Value of the SqlParameter object to find.
true if the collection contains the parameter; otherwise, false.
The following example shows use of the Contains property to find an SqlParameter with a given Value within the Parameters collection of a specifed SqlCommand object. If the parameter exists, the example displays the index of the parameter; otherwise, the example displays an error.
public void SearchSqlParams ( SqlCommand myCmd ) {
SqlParameterCollection myParams = myCmd.Parameters;
if ( myParams.Contains ( ( Object ) myParam ) )
MessageBox.Show ( "Match found on parameter " +
myParams.IndexOf ( ( Object ) myParam ).ToString ( ) );
else
MessageBox.Show ( "Sorry, no such parameter found in the collection" );
}
Public Sub SearchSqlParams ( ByVal myCmd As SqlCommand )
Dim myParams As SqlParameterCollection = myCmd.Parameters
If myParams.Contains ( CType ( myParam, Object ) ) Then
MessageBox.Show ( "Match found on parameter " & _
myParams.IndexOf ( CType ( myParam, Object ) ).ToString ( ) )
Else
MessageBox.Show ( "Sorry, no such parameter found in the collection" )
End If
End Sub |
|
C# |
VB |
SqlParameterCollection Members SqlParameterCollection.Contains Overload List