OdbcParameterCollection.Contains Method (String)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets a value indicating whether an OdbcParameter object with the specified parameter name exists in the collection.

Namespace:   System.Data.Odbc
Assembly:  System.Data (in System.Data.dll)

public override bool Contains(
	string value
)

Parameters

value
Type: System.String

The name of the OdbcParameter object to find.

Return Value

Type: System.Boolean

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

The following example searches for an OdbcParameter with a given ParameterName within an OdbcParameterCollection. If the parameter exists, the example displays the name and index of the parameter. If the parameter does not exist, the example displays an error. This example assumes that an OdbcParameterCollection has already been created.

public void SearchParameters() 
{
    // ...
    // create OdbcParameterCollection parameterCollection
    // ...
    if (!parameterCollection.Contains("Description"))
        Console.WriteLine("ERROR: no such parameter in the collection");
    else
        Console.WriteLine("Name: " + parameterCollection["Description"].ToString() +
            "Index: " + parameterCollection.IndexOf("Description").ToString());
}

.NET Framework
Available since 1.1
Return to top
Show: