System.Data.OleDb Namespace OleDbParameterCollection Class
Returns the location of a given OleDbParameter within the collection.
[ VB ]
Overloads Public Function IndexOf ( _
ByVal parameter As Object _
) As Integer
[ C# ]
public int IndexOf (
object parameter
);
[ C++ ]
public: int IndexOf (
Object* parameter
);
[ JScript ]
public function IndexOf (
parameter : Object
) : int;
- parameter
- The OleDbParameter object to locate.
The location of the OleDbParameter within the collection.
The following example first uses the Contains property to find an OleDbParameter with a given Value within the Parameters collection of a specifed OleDbCommand object. If the parameter exists, the example use the IndexOf method to display the index of the parameter; otherwise, the example displays an error.
public void SearchOleDbParams ( OleDbCommand myCmd ) {
OleDbParameterCollection 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 SearchOleDbParams ( ByVal myCmd As OleDbCommand )
Dim myParams As OleDbParameterCollection = myCmd.Parameters
If myParams.Contains ( CType ( myParam, Object ) ) Then
MessageBox.Show ( "Match found on parameter " & _
myParams.IndexOf ( CType ( myNewParam, Object ).ToString ( ) )
Else
MessageBox.Show ( "Sorry, no such parameter found in the collection" )
End If
End Sub |
|
C# |
VB |
OleDbParameterCollection Members OleDbParameterCollection.IndexOf Overload List