OdbcParameterCollection.Item Property (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 or sets the OdbcParameter with the specified name.

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

[BrowsableAttribute(false)]
public OdbcParameter this[
	string parameterName
] { get; set; }

Parameters

parameterName
Type: System.String

The name of the parameter to retrieve.

Property Value

Type: System.Data.Odbc.OdbcParameter

The OdbcParameter with the specified name.

Exception Condition
IndexOutOfRangeException

The name specified does not exist.

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: