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
public override int IndexOf (
Object value
)
public:
virtual int IndexOf (
Object^ value
) override
public int IndexOf (
Object value
)
public override function IndexOf (
value : Object
) : int
Parameters
- value
The SqlCeParameter object to locate.
Return Value
The zero-based location of the SqlCeParameter in the collection.
Example
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());
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