Share via


SqlCeParameterCollection.IndexOf Method (String)

Gets the location of the SqlCeParameter in the collection with the specified parameter name.

Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in system.data.sqlserverce.dll)

Syntax

'Declaration
Public Overrides Function IndexOf ( _
    parameterName As String _
) As Integer
public override int IndexOf (
    string parameterName
)
public:
virtual int IndexOf (
    String^ parameterName
) override
public int IndexOf (
    String parameterName
)
public override function IndexOf (
    parameterName : String
) : int

Parameters

  • parameterName
    The name of the parameter to find.

Return Value

The location of the SqlCeParameter in the collection.

Example

The following example searches for a SqlCeParameter with a given ParameterName 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
' ...
If Not cmd.Parameters.Contains("Description") Then
    MessageBox.Show("ERROR: no such parameter in the collection")
Else
    MessageBox.Show("match on parameter #" & cmd.Parameters.IndexOf("Description").ToString())
End If
// ...
// create SqlCeCommand cmd
// ...
if (!cmd.Parameters.Contains("Description"))
    MessageBox.Show("ERROR: no such parameter in the collection");
else
    MessageBox.Show("match on parameter #" +
        cmd.Parameters.IndexOf("Description").ToString());

Thread Safety

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows Vista, Windows Mobile 5.0, Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Mobile 2003 for Pocket PC, Windows CE 5.0
Version Information
.NET Framework and NET Compact Framework
Supported in 3.5
.NET Framework
Supported in 3.0
.NET Compact Framework and .Net Framework
Supported in 2.0

See Also

Reference

SqlCeParameterCollection Class
SqlCeParameterCollection Members
System.Data.SqlServerCe Namespace