Export (0) Print
Expand All

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)

public override int IndexOf(
	string parameterName
)

Parameters

parameterName
Type: System.String
The name of the parameter to find.

Return Value

Type: System.Int32
The location of the SqlCeParameter in the collection.

Implements

IDataParameterCollection.IndexOf(String)

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 (!cmd.Parameters.Contains("Description"))
    MessageBox.Show("ERROR: no such parameter in the collection");
else
    MessageBox.Show("match on parameter #" +
        cmd.Parameters.IndexOf("Description").ToString());


Show:
© 2015 Microsoft