SqlCeParameterCollection.IndexOf Method (Object)
Gets the location of the SqlCeParameter object in the collection.
Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)
Syntax
'Declaration
Public Overrides Function IndexOf ( _
value As Object _
) As Integer
'Usage
Dim instance As SqlCeParameterCollection
Dim value As Object
Dim returnValue As Integer
returnValue = instance.IndexOf(value)
public override int IndexOf(
Object value
)
public:
virtual int IndexOf(
Object^ value
) override
abstract IndexOf :
value:Object -> int
override IndexOf :
value:Object -> int
public override function IndexOf(
value : Object
) : int
Parameters
- value
Type: System.Object
The SqlCeParameter object to locate.
Return Value
Type: System.Int32
The zero-based location of the SqlCeParameter in the collection.
Implements
Examples
The following example searches for a SqlCeParameter within a SqlCeParameterCollection. 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 SqlCeCommand has already been created.
' ...
' create SqlCeCommand cmd
' ...
Dim myParam As SqlCeParameter = cmd.Parameters.Add("@Description", SqlDbType.NVarChar)
If Not cmd.Parameters.Contains(myParam) Then
MessageBox.Show("ERROR: no such parameter in the collection")
Else
MessageBox.Show("match on parameter #" & cmd.Parameters.IndexOf(myParam).ToString())
End If
// ...
// create SqlCeCommand cmd
// ...
SqlCeParameter myParam = cmd.Parameters.Add("@Description", SqlDbType.NVarChar);
if (!cmd.Parameters.Contains(myParam))
MessageBox.Show("ERROR: no such parameter in the collection");
else
MessageBox.Show("match on parameter #" +
cmd.Parameters.IndexOf(myParam).ToString());