Compartilhar via


SqlCeParameterCollection.Contains Method (Object)

Gets a value indicating whether or not a SqlCeParameter object exists in the collection.

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

Syntax

'Declaration
Public Overrides Function Contains ( _
    value As Object _
) As Boolean
'Usage
Dim instance As SqlCeParameterCollection
Dim value As Object
Dim returnValue As Boolean

returnValue = instance.Contains(value)
public override bool Contains (
    Object value
)
public:
virtual bool Contains (
    Object^ value
) override
public boolean Contains (
    Object value
)
public override function Contains (
    value : Object
) : boolean
Not applicable.

Parameters

Return Value

true if the collection contains the SqlCeParameter; otherwise, false.

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

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