System.Data.OleDb Namespace OleDbParameterCollection Class
Checks whether an OleDbParameter with the specified name is in the collection.
[ VB ]
Overloads Public Function Contains ( _
ByVal value As String _
) As Boolean
[ C# ]
public bool Contains (
string value
);
[ C++ ]
public: bool Contains (
String* value
);
[ JScript ]
public function Contains (
value : String
) : Boolean
- value
- The name of the parameter to retrieve.
true if the collection contains the parameter; otherwise, false.
IDataParameterCollection.Contains
The following example shows use of the Contains property to find an OleDbParameter with a given ParameterName within the Parameters collection of a specifed OleDbCommand object. If the parameter exists, the example displays the index of the parameter; otherwise, the example displays an error.
public void SearchOleDbParams ( OleDbCommand myCmd ) {
OleDbParameterCollection myParams = myCmd.Parameters;
if ( myParams.Contains ( "Model" ) )
MessageBox.Show ( "Name: " + myParams [ "Model" ].ToString ( ) +
"Index: " + myParams.IndexOf ( "Model" ).ToString ( ) );
else
MessageBox.Show ( "Sorry, no such parameter found in the collection" );
}
Public Sub SearchOleDbParams ( ByVal myCmd As OleDbCommand )
Dim myParams As OleDbParameterCollection = myCmd.Parameters
If myParams.Contains ( "Model" ) Then
MessageBox.Show ( "Name: " & myParams ( "Model" ).ToString ( ) & _
"Index: " & myParams.IndexOf ( "Model" ).ToString ( ) )
Else
MessageBox.Show ( "Sorry, no such parameter found in the collection" )
End If
End Sub |
|
C# |
VB |
OleDbParameterCollection Members OleDbParameterCollection.Contains Overload List