This documentation is archived and is not being maintained.

OracleConnectionStringBuilder Constructor (String)

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

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

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

'Declaration
Public Sub New ( _
	connectionString As String _
)
'Usage
Dim connectionString As String

Dim instance As New OracleConnectionStringBuilder(connectionString)
public OracleConnectionStringBuilder (
	String connectionString
)
public function OracleConnectionStringBuilder (
	connectionString : String
)

Parameters

connectionString

The basis for the object's internal connection information. Parsed into name/value pairs. Invalid key names raise a KeyNotFoundException.

Exception typeCondition

KeyNotFoundException

Invalid key name within the connection string.

FormatException

Invalid value within the connection string (specifically, when a Boolean or numeric value was expected but not supplied).

The OracleConnectionStringBuilder class provides a fixed internal collection of key/value pairs. Even if you supply only a small subset of the possible connection string values in the constructor, the object always provides default values for each key/value pair. When the ConnectionString property of the object is retrieved, the string contains only key/value pairs in which the value is different from the default value for the item.

The following example supplies a simple connection string in the OracleConnectionStringBuilder object's constructor, and then iterates through all the key/value pairs within the object. Note that the collection provides default values for each items. Also note that the OracleConnectionStringBuilder class converts synonyms for the well-known keys so that they are consistent with the well-known names.

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()
    Try
      Dim connectString As String = "Server=OracleDemo;UID=Mary;Pwd=*****"
      Console.WriteLine("Original: " & connectString)
      Dim builder As New OracleConnectionStringBuilder(connectString)
      Console.WriteLine("Modified: " & builder.ConnectionString)
      For Each key As String In builder.Keys
        Console.WriteLine(key & "=" & builder.Item(key).ToString)
      Next
      Console.WriteLine("Press any key to finish.")
      Console.ReadLine()

    Catch ex As System.Collections.Generic.KeyNotFoundException
      Console.WriteLine("KeyNotFoundException: " & ex.Message)
    Catch ex As System.FormatException
      Console.WriteLine("Format exception: " & ex.Message)
    End Try
  End Sub

End Module

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
Show: