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)

System.Object
  System.Data.Common.DbConnectionStringBuilder
    System.Data.OracleClient.OracleConnectionStringBuilder

<ObsoleteAttribute("OracleConnectionStringBuilder has been deprecated. http://go.microsoft.com/fwlink/?LinkID=144260",
	False)>
Public NotInheritable Class OracleConnectionStringBuilder
	Inherits DbConnectionStringBuilder

NameDescription
System_CAPS_pubmethodOracleConnectionStringBuilder()

Initializes a new instance of the OracleConnectionStringBuilder class.

System_CAPS_pubmethodOracleConnectionStringBuilder(String)

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

NameDescription
System_CAPS_pubpropertyBrowsableConnectionString

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

System_CAPS_pubpropertyConnectionString

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

System_CAPS_pubpropertyCount

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

System_CAPS_pubpropertyDataSource

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

System_CAPS_pubpropertyEnlist

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

System_CAPS_pubpropertyIntegratedSecurity

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).

System_CAPS_pubpropertyIsFixedSize

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

System_CAPS_pubpropertyIsReadOnly

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

System_CAPS_pubpropertyItem(String)

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

System_CAPS_pubpropertyKeys

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

System_CAPS_pubpropertyLoadBalanceTimeout

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

System_CAPS_pubpropertyMaxPoolSize

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

System_CAPS_pubpropertyMinPoolSize

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

System_CAPS_pubpropertyOmitOracleConnectionName

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

System_CAPS_pubpropertyPassword

Gets or sets the password for the Oracle account.

System_CAPS_pubpropertyPersistSecurityInfo

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.

System_CAPS_pubpropertyPooling

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.

System_CAPS_pubpropertyUnicode

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.

System_CAPS_pubpropertyUserID

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

System_CAPS_pubpropertyValues

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

NameDescription
System_CAPS_pubmethodAdd(String, Object)

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

System_CAPS_pubmethodClear()

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

System_CAPS_protmethodClearPropertyDescriptors()

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

System_CAPS_pubmethodContainsKey(String)

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

System_CAPS_pubmethodEquals(Object)

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

System_CAPS_pubmethodEquivalentTo(DbConnectionStringBuilder)

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

System_CAPS_pubmethodGetHashCode()

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

System_CAPS_pubmethodGetType()

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

System_CAPS_pubmethodRemove(String)

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

System_CAPS_pubmethodShouldSerialize(String)

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

System_CAPS_pubmethodToString()

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).)

NameDescription
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.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDictionary.Contains(Object)

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDictionary.GetEnumerator()

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDictionary.Remove(Object)

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodIEnumerable.GetEnumerator()

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetAttributes()

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetClassName()

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetComponentName()

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetConverter()

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetDefaultEvent()

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetDefaultProperty()

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetEditor(Type)

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetEvents()

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetEvents(Attribute())

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetProperties()

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetProperties(Attribute())

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor)

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

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.IsSynchronized

Gets a value indicating whether access to the ICollection is synchronized (thread safe).(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.SyncRoot

Gets an object that can be used to synchronize access to the ICollection.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIDictionary.Item(Object)

Gets or sets the element with the specified key.(Inherited from DbConnectionStringBuilder.)

NameDescription
System_CAPS_pubmethodAsParallel()

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

System_CAPS_pubmethodAsQueryable()

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

System_CAPS_pubmethodCast(Of TResult)()

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

System_CAPS_pubmethodOfType(Of TResult)()

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. _
    OracleClient.OracleConnectionStringBuilder
builder("Data Source") = "OracleDemo"
builder("Integrated Security") = True
builder("User ID") = "Mary;NewValue=Bad"
System.Diagnostics.Debug.WriteLine(builder.ConnectionString)

[C#]

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

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.

System_CAPS_noteNote

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 running this example.
Imports System.Data.OracleClient

Module Module1
  Sub Main()
    ' Create a new OracleConnectionStringBuilder and
    ' initialize it with a few name/value pairs.
    Dim builder As 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.
    Console.WriteLine(builder.ConnectionString)

    ' Pass the OracleConnectionStringBuilder an existing 
    ' connection string, and you can retrieve and
    ' modify any of the elements.
    builder.ConnectionString = _
        "server=OracleDemo;user id=Mary;" & _
        "password=*****"
    ' Now that the connection string has been parsed,
    ' you can work with individual items.
    Console.WriteLine(builder.Password)
    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") = "NewDemo"
    builder("Load Balance Timeout") = 1000

    ' The Item property is the default for the class, 
    ' and setting the Item property adds the value to the 
    ' dictionary, if necessary. 
    builder.Item("Integrated Security") = True
    Console.WriteLine(builder.ConnectionString)

    Console.WriteLine("Press Enter to finish.")
    Console.ReadLine()
  End Sub

  Private Function GetConnectionString() As String
    ' To avoid storing the connection string in your code,
    ' you can retrieve it from a configuration file. 
    Return "Server=OracleDemo;Integrated Security=True;" & _
      "Unicode=True"
  End Function

End Module

.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
Show:
© 2016 Microsoft