Export (0) Print
Expand All

DbConnectionStringBuilder::Add Method

Adds an entry with the specified key and value into the DbConnectionStringBuilder.

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

public:
void Add(
	String^ keyword, 
	Object^ value
)

Parameters

keyword
Type: System::String
The key to add to the DbConnectionStringBuilder.
value
Type: System::Object
The value for the specified key.

ExceptionCondition
ArgumentNullException

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

NotSupportedException

The DbConnectionStringBuilder is read-only.

-or-

The DbConnectionStringBuilder has a fixed size.

The Item property can also be used to add new elements by setting the value of a key that does not exist in the dictionary. For example: myCollection["myNonexistentKey"] = myValue.

Calling the Add method by passing a null (Nothing in Visual Basic) key throws an ArgumentNullException. However, calling the Add method by passing a null value removes the key/value pair.

The following example creates a new DbConnectionStringBuilder and adds items. The code also demonstrates overwriting an existing item using the Add method, and includes a commented block that would throw an ArgumentNullException.

NoteNote

This example includes a password to demonstrate how DbConnectionStringBuilder works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Community Additions

ADD
Show:
© 2014 Microsoft