This documentation is archived and is not being maintained.

OdbcConnectionStringBuilder.Item Property

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 System.Data.dll)

public override Object this[
	string keyword
] { get; set; }


Type: System.String

The key of the item to get or set.

Property Value

Type: System.Object
The value associated with the specified key.


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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0