Partilhar 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
'Usage
Dim instance As SqlCeParameterCollection
Dim parameterName As String
Dim returnValue As Integer

returnValue = instance.IndexOf(parameterName)
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
Not applicable.

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());

Platforms

Windows CE, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows XP Professional x64 Edition, Windows XP SP2

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

.NET Compact Framework

Supported in: 2.0, 1.0

See Also

Reference

SqlCeParameterCollection Class
SqlCeParameterCollection Members
System.Data.SqlServerCe Namespace