DbConnectionStringBuilder.Item Property

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

Gets or sets the value associated with the specified key.

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

Public Overridable Default Property Item ( _
	keyword As String _
) As Object
Dim instance As DbConnectionStringBuilder
Dim keyword As String
Dim value As Object

value = instance(keyword)

instance(keyword) = value
/** @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. If the specified key is not found, trying to get it returns a null reference (Nothing in Visual Basic), and trying to set it creates a new element using the specified key. Passing a null (Nothing in Visual Basic) key throws an ArgumentNullException. Assigning a null value removes the key/value pair.

Exception typeCondition


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


The property is set, and the DbConnectionStringBuilder is read-only.


The property is set, keyword does not exist in the collection, and the DbConnectionStringBuilder has a fixed size.

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 console application creates a new DbConnectionStringBuilder and adds key/value pairs to its connection string, using the Item property.

Module Module1

    Sub Main()
        Dim builder As New DbConnectionStringBuilder
        builder.Item("Data Source") = "(local)"

        ' Item is the default property, so 
        ' you need not include it in the reference.
        builder("integrated security") = True
        builder.Item("Initial Catalog") = "AdventureWorks"

        ' Overwrite the existing value for the data source value, 
        ' because it already exists within the collection.
        builder.Item("Data Source") = "."

        Console.WriteLine("Press Enter to continue.")
    End Sub

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