Item Property
Collapse the table of content
Expand the table of content

OdbcConnectionStringBuilder.Item Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets the value associated with the specified key. In C#, this property is the indexer.

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

public override Object this [
	string keyword
] { get; set; 
/** @property */
public Object get_Item (String keyword)

/** @property */
public void set_Item (String keyword, Object value)

JScript supports the use of indexed properties, but not the declaration of new ones.



The key of the item to get or set.

Property Value

The value associated with the specified key.

Exception typeCondition


The connection string is incorrectly formatted (perhaps missing the required "=" within a key/value pair).


keyword is a null reference (Nothing in Visual Basic).

When you set this property, if the specified key already exists in the dictionary, the value is replaced; otherwise, a new element is created.

The following code, in a console application, creates a new OdbcConnectionStringBuilder and adds key/value pairs to its connection string, using the Item property.

using System.Data.Odbc;

class Program
    static void Main()
        OdbcConnectionStringBuilder builder = 
            new OdbcConnectionStringBuilder();
        // Set up a connection string for a text file.
        builder["Driver"] = "Microsoft Text Driver (*.txt; *.csv)";
        builder["dbq"] = "C:\\TextFilesFolder";
        builder["Extension"] = "asc,csv,tab,txt";

        // Overwrite the existing value for the dbq value, 
        // because it already exists within the collection.
        builder["dbq"] = "D:\\";

        Console.WriteLine("Press Enter to continue.");

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

© 2016 Microsoft