OleDbConnectionStringBuilder::Item Property (String^)
Gets or sets the value associated with the specified key. In C#, this property is the indexer.
Assembly: System.Data (in System.Data.dll)
public: property Object^ default[ String^ keyword ] { virtual Object^ get(String^ keyword) override; virtual void set(String^ keyword, Object^ value) override; }
Parameters
- keyword
-
Type:
System::String^
The key of the item to get or set.
| Exception | Condition |
|---|---|
| ArgumentException | The connection string is incorrectly formatted (perhaps missing the required "=" within a key/value pair). |
| ArgumentNullException | keyword is a null reference (Nothing in Visual Basic). |
Because setting the Provider property may add corresponding items to the collection of key/value pairs (depending on the behavior of the specific provider), you may be able to retrieve a value for a key you have not set explicitly. For example, as soon as you have set the Provider property to "sqloledb," you can retrieve the "Workstation ID" value even if you have not set it yourself. See the example in this topic for a demonstration.
The following example uses the Item property (the indexer, in C#) to retrieve and set values within the collection of key/value pairs. Note that setting the provider, in this case, also provides default values for all the key/value pairs associated with the selected provider.
Available since 2.0