OracleConnectionStringBuilder Class

OracleConnectionStringBuilder Class

Note: This API is now obsolete.

Provides a simple way to create and manage the contents of connection strings used by the OracleConnection class.

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


[ObsoleteAttribute("OracleConnectionStringBuilder has been deprecated.", 
public sealed class OracleConnectionStringBuilder : DbConnectionStringBuilder


Initializes a new instance of the OracleConnectionStringBuilder class.


Initializes a new instance of the OracleConnectionStringBuilder class. The provided connection string provides the data for the instance's internal connection information.


Gets or sets a value that indicates whether the ConnectionString property is visible in Visual Studio designers.(Inherited from DbConnectionStringBuilder.)


Gets or sets the connection string associated with the DbConnectionStringBuilder.(Inherited from DbConnectionStringBuilder.)


Gets the current number of keys that are contained within the ConnectionString property.(Inherited from DbConnectionStringBuilder.)


Gets or sets the name of the Oracle data source to connect to.


Gets or sets a value that indicates whether the pooler automatically enlists the connection in the creation thread's current transaction context.


Gets or sets a value that indicates whether "User ID" and "Password" are specified in the connection (when false) or whether the current Windows account credentials are used for authentication (when true).


Gets a value that indicates whether the OracleConnectionStringBuilder has a fixed size.(Overrides DbConnectionStringBuilder.IsFixedSize.)


Gets a value that indicates whether the DbConnectionStringBuilder is read-only.(Inherited from DbConnectionStringBuilder.)


Gets or sets the value associated with the specified key. In C#, this property is the indexer.(Overrides DbConnectionStringBuilder.Item[String].)


Gets an ICollection that contains the keys in the OracleConnectionStringBuilder.(Overrides DbConnectionStringBuilder.Keys.)


Gets or sets the minimum time, in seconds, for the connection to live in the connection pool before it is removed.


Gets or sets the maximum number of connections allowed in the connection pool for this specific connection string.


Gets or sets the minimum number of connections allowed in the connection pool for this specific connection string.


Gets or sets the flag that enables transaction rollbacks on earlier versions of Oracle (prior to


Gets or sets the password for the Oracle account.


Gets or sets a Boolean value that indicates if security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state.


Gets or sets a Boolean value that indicates whether the connection will be pooled, or whether each connection will be explicitly opened every time that the connection is requested.


Gets or sets a Boolean value that indicates if the client supports the Unicode functionality available in later Oracle clients, or if it is non-Unicode aware.


Gets or sets the user ID to be used when connecting to Oracle.


Gets an ICollection that contains the values in the OracleConnectionStringBuilder.(Overrides DbConnectionStringBuilder.Values.)

System_CAPS_pubmethodAdd(String, Object)

Adds an entry with the specified key and value into the DbConnectionStringBuilder.(Inherited from DbConnectionStringBuilder.)


Clears the contents of the OracleConnectionStringBuilder instance.(Overrides DbConnectionStringBuilder.Clear().)


Clears the collection of PropertyDescriptor objects on the associated DbConnectionStringBuilder.(Inherited from DbConnectionStringBuilder.)


Determines whether the OracleConnectionStringBuilder contains a specific key.(Overrides DbConnectionStringBuilder.ContainsKey(String).)


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Compares the connection information in this DbConnectionStringBuilder object with the connection information in the supplied object.(Inherited from DbConnectionStringBuilder.)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Removes the entry with the specified key from the OracleConnectionStringBuilder instance.(Overrides DbConnectionStringBuilder.Remove(String).)


Indicates whether the specified key exists in this OracleConnectionStringBuilder instance.(Overrides DbConnectionStringBuilder.ShouldSerialize(String).)


Returns the connection string associated with this DbConnectionStringBuilder.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubmethodTryGetValue(String, Object)

Retrieves a value corresponding to the supplied key from this OracleConnectionStringBuilder.(Overrides DbConnectionStringBuilder.TryGetValue(String, Object).)

System_CAPS_pubinterfaceSystem_CAPS_privmethodICollection.CopyTo(Array, Int32)

Copies the elements of the ICollection to an Array, starting at a particular Array index.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDictionary.Add(Object, Object)

Adds an element with the provided key and value to the IDictionary object.(Inherited from DbConnectionStringBuilder.)


Determines whether the IDictionary object contains an element with the specified key.(Inherited from DbConnectionStringBuilder.)


Returns an IDictionaryEnumerator object for the IDictionary object.(Inherited from DbConnectionStringBuilder.)


Removes the element with the specified key from the IDictionary object.(Inherited from DbConnectionStringBuilder.)


Returns an enumerator that iterates through a collection.(Inherited from DbConnectionStringBuilder.)


Returns a collection of custom attributes for this instance of a component.(Inherited from DbConnectionStringBuilder.)


Returns the class name of this instance of a component.(Inherited from DbConnectionStringBuilder.)


Returns the name of this instance of a component.(Inherited from DbConnectionStringBuilder.)


Returns a type converter for this instance of a component.(Inherited from DbConnectionStringBuilder.)


Returns the default event for this instance of a component.(Inherited from DbConnectionStringBuilder.)


Returns the default property for this instance of a component.(Inherited from DbConnectionStringBuilder.)


Returns an editor of the specified type for this instance of a component.(Inherited from DbConnectionStringBuilder.)


Returns the events for this instance of a component.(Inherited from DbConnectionStringBuilder.)


Returns the events for this instance of a component using the specified attribute array as a filter.(Inherited from DbConnectionStringBuilder.)


Returns the properties for this instance of a component.(Inherited from DbConnectionStringBuilder.)


Returns the properties for this instance of a component using the attribute array as a filter.(Inherited from DbConnectionStringBuilder.)


Returns an object that contains the property described by the specified property descriptor.(Inherited from DbConnectionStringBuilder.)


Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)


Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)


Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)


Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.)

This type is deprecated and will be removed in a future version of the .NET Framework. For more information, see Oracle and ADO.NET.

The connection string builders allow developers to programmatically create syntactically correct connection strings, and to parse and rebuild existing connection strings, using properties and methods of the class. The connection string builder provides strongly typed properties corresponding to the known key/value pairs allowed by Oracle. The OracleConnectionStringBuilder class implements the ICustomTypeDescriptor interface. This means that the class works with Visual Studio .NET designers at design time. When developers use the designer to build strongly typed DataSets and strongly typed connections within Visual Studio .NET, the strongly typed connection string builder class will display the properties associated with its type and will also have converters that can map common values for known keys.

Developers needing to create connection strings as part of applications can use the OracleConnectionStringBuilder class to build and modify connection strings. The OracleConnectionStringBuilder class also makes it easy to manage connection strings stored in an application configuration file.

The OracleConnectionStringBuilder performs checks for valid key/value pairs. Therefore, this class cannot be used to create invalid connection strings. Trying to add invalid pairs will throw an exception. The OracleConnectionStringBuilder class maintains a fixed collection of synonyms, and when required, can perform the required translation to convert from a synonym to the corresponding well-known key name. For example, when you use the Item property to retrieve a value, you can specify a string that contains any synonym for the key you need. See the Item property for a full list of acceptable synonyms.

The OracleConnectionStringBuilder handles attempts to insert malicious entries. For example, the following code, using the default Item property (the indexer, in C#) correctly escapes the nested key/value pair.

[Visual Basic]

Dim builder As New System.Data. _
builder("Data Source") = "OracleDemo"
builder("Integrated Security") = True
builder("User ID") = "Mary;NewValue=Bad"


System.Data.OracleClient.OracleConnectionStringBuilder builder =
   new System.Data.OracleClient.OracleConnectionStringBuilder();
builder["Data Source"] = "OracleDemo";
builder["integrated Security"] = true;
builder["User ID"] = "Mary;NewValue=Bad";

The result is the following connection string that handles the invalid value in a safe manner by enclosing the User ID value in quotes:

Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad"

The following console application builds connection strings for an Oracle database. The code uses an OracleConnectionStringBuilder class to create the connection string, and then passes the P:System.Data.OracleClient.OracleConnectionStringBuilder.ConnectionString property of the OracleConnectionStringBuilder instance to the constructor of the connection class. The example also parses an existing connection string, and demonstrates various ways of manipulating the connection string's contents.


This example includes a password to demonstrate how OracleConnectionStringBuilder 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.

// You may need to set a reference to the System.Data.OracleClient
// assembly before you can run this sample.
using System.Data.OracleClient;

class Program
    static void Main()
        // Create a new OracleConnectionStringBuilder and
        // initialize it with a few name/value pairs.
        OracleConnectionStringBuilder builder =
            new OracleConnectionStringBuilder(GetConnectionString());

        // Note that the input connection string used the 
        // Server key, but the new connection string uses
        // the well-known Data Source key instead.

        // Pass the OracleConnectionStringBuilder an existing 
        // connection string, and you can retrieve and
        // modify any of the elements.
        builder.ConnectionString = "server=OracleDemo;user id=maryc;" +

        // Now that the connection string has been parsed,
        // you can work with individual items.
        builder.Password = "newPassword";
        builder.PersistSecurityInfo = true;

        // You can refer to connection keys using strings, 
        // as well. When you use this technique (the default
        // Item property in Visual Basic, or the indexer in C#),
        // you can specify any synonym for the connection string key
        // name.
        builder["Server"] = ".";
        builder["Load Balance Timeout"] = 1000;
        builder["Integrated Security"] = true;

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

    private static string GetConnectionString()
        // To avoid storing the connection string in your code,
        // you can retrieve it from a configuration file. 
        return "Server=OracleDemo;Integrated Security=true";

.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
© 2015 Microsoft