See Also

OracleConnection Class  | OracleConnection Members  | Open Method

Language

Visual Basic

C#

Show All

See AlsoLanguagesDevart.Data.OracleSend comments on this topic.

ConnectionString Property

Devart.Data.Oracle Namespace > OracleConnection Class : ConnectionString Property (OracleConnection)

Gets or sets the string used to open an Oracle server database.

[Visual Basic]
Public Property ConnectionString As String
[C#]
public string ConnectionString {get; set;}

Return Type

The connection string that includes the source database name, and other parameters needed to establish the initial connection. The default value is an empty string ("").

Remarks

The ConnectionString property can be set only when the connection is closed; setting ConnectionString of an opened connection closes this connection. Many of the connection string values have corresponding properties. When the connection string is set, all of these properties are updated, except when an error is detected. In this case, none of the properties are updated. OracleConnection properties return only those settings contained in the ConnectionString.

Resetting the ConnectionString on a closed connection resets all connection string values (and related properties) including the password. For example, if you set a connection string that includes "Home = OraClient11g_Home1", and then reset the connection string to "Data Source=ora; User ID = Scott; Password = tiger", the Home property is no longer set to 'OraClient11g_Home1'.

The connection string is parsed immediately after being set. If errors in syntax are found when parsing, a runtime exception, such as ArgumentException, is generated. Other errors can be found only when an attempt is made to open the connection.

The ConnectionString property format is the same as for common ADO.NET connection strings. Connection string consists of pairs of parameter name and parameter value connected by the equal sign (=). Each pair should be separated from the previous one by a semicolon. Parameter values may be specified inside single or double qotes, (for example, name='value' or name="value"). Either single or double quotes may be used in a value if it is set using another type of quotes, for example, name="value's" or name= 'value"s', but not name= 'value's' or name= ""value"". If a semicolon is a part of a value, the value must be quoted. All blank characters, except those placed within a value or within quotes, are ignored. No escape sequences are supported. The value type is irrelevant. Parameter names are case insensitive. Arguments names may occur only once in the connection string.

The following table lists the valid names for values within the ConnectionString.

NameDescription
Connect ModeAllows to open a session with administrative privileges SYSDBA or SYSOPER.
Connection ClassConnection class for Oracle's Database Resident Connection Pooling (DRCP). You need to set also OCI Session Pooling = true for using DRCP. DRCP is supported starting with Oracle 11g.
Connection LifetimeWhen a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by Connection Lifetime. The default value is 0.
Connection TimeoutTime (in seconds) to wait while trying to establish a connection before terminating the attempt and generating an error. A value of 0 indicates no limit. The default value is 15 seconds.
Data Source -or- Server -or- HostThe name of TNS alias of Oracle database to which to connect. For more information refer to Server property.
Default Command TimeoutThe time in seconds to wait while trying to execute a command before terminating the attempt and generating an error. 0 indicates no limit.
DirectIf true, dotConnect for Oracle can operate without an Oracle client installed. The default value is false.
EnlistDetermines whether the connection is automatically enlisted in the current distributed transaction. The default value is true. This parameter is not available in Mobile Edition.
HomeThe Oracle Home that will be used.
Initialization CommandSpecifies the size of a block (in megabytes) to read/write CLOB or NCLOB data from/to database. This option is supported in OCI mode only. Applicable only for Unicode Oracle servers. Default value is 0, which means that the whole value is sent in one block. If you get errors when reading/writing huge LOB values, try setting this property to 8, it is the safest value.
Lob Block SizeSpecifies a database-specific command that should be executed immediately after establishing the connection.
Max Pool SizeThe maximum number of connections allowed in the pool. Setting the Max Pool Size value of the ConnectionString can affect performance. The default value is 100.
Min Pool SizeThe minimum number of connections allowed in the pool. The default value is 0.
Number Mappings

Sets the number mappings used for this connection. Each mapping is set as (OracleNumberType, FromPrecision, ToPrecision, SystemType), where:

- OracleNumberType is one of the values from OracleNumberType enumeration;
FromPrecision and ToPrecision set the minimal and maximal precisions of the Oracle number type to map with this mapping;
SystemType is a .NET type to which Oracle number type should be mapped.

Several mappings should be separated by commas and covered by a common parentheses. For example, this property may be set as:
Number Mappings = (Integer, 1, 1, System.Boolean)
or
Number Mappings = ((Integer, 1, 5, System.Int16), (FLOAT,12,15,System.Decimal), (NUMBER,7,9,System.Single))

Oci Session PoolingIf true, enables the OCI Session Pooling feature. In this mode the dotConnect for Oracle pool is disabled.
Oci Session Pool Allow WaitingIf true, new connections wait for an existing one to close if Max Size is reached; otherwise an exception is thrown.
Oci Session Pool Connection LifetimeThis attribute specifies the lifetime of the connection in seconds. Before the Connection is placed back into the pool, the lifetime of the connection is checked. If the lifetime of the connection exceeds this property value, the connection is closed and disposed. If this property value is 0, the connection lifetime is never checked.
Oci Session Pool IncrementAllows applications to set the next increment for sessions to be started if the current number of sessions is less than Max Size. The valid values are 1 and above.
Oci Session Pool Max SizeSpecifies the maximum number of sessions that can be opened in the session pool. Once this value is reached, no more sessions are opened. The valid values are 1 and above.
Oci Session Pool Min SizeSpecifies the minimum number of sessions in the session pool. This number of sessions are started initially. After this, sessions are opened only when necessary.
Oci Session Pool PasswordIf set, defines password for proxy user.
Oci Session Pool User IdIf set, defines user name for proxy user. Available only when OCI Session Pooling is enabled. If you want to have proxy connections without OCI Session Pooling, use the Open overload that accepts another OracleConnection as argument.
OraMtsIf set to true, Oracle Services for Microsoft Transaction Server (OraMTS) is used for distributed transactions; otherwise OraMTS is not used.
Pass Parameters By NamePass parameters by name to the stored procedure calls. If set to true, parameters will be passed by name regardless of individual OracleCommand.PassParametersByName values. Default value is false.
PasswordThe password for the Oracle login account. Leave blank if you want to use Integrated Security connections (OS authentication)
PoolingIf true, by default, the OracleConnection object is drawn from the appropriate pool or is created and added to the appropriate pool.
PortNumber of a port to communicate with listener on the server to use in OracleConnection.Direct mode. The default value is 1521.
Service NameAlias to an Oracle database instance (or many instances) to use in the OracleConnection.Direct mode. The default value is empty string. When Service Name is specified and implies several database instances, dotConnect for Oracle connects to the first instance provided by Oracle listener. Note that RAC is not supported in the Direct mode, and provider works only with this one database instance.
SIDUnique name for an Oracle database instance to use in the OracleConnection.Direct mode. The default value is empty string.
Statement Cache SizeThis attribute enables or disables statement caching. Its value specifies the maximum number of statements that can be cached for a connection. By default this attribute is set to 0 (disabled). Statement caching starts if this parameter is set to a value more than 0. It should not be more than MAX_OPEN_CURSORS parameter in an Oracle database.
Transaction Scope LocalIf there are several connections with the same connection string (which includes "Transaction Scope Local=true;") within a scope of TransactionScope, our provider will use only one connection internally. The default value is false. Not available in Mobile Edition.
Trim Fixed CharSpecifies whether to trim trailing spaces when reading data from fixed-length string data types (CHAR, NCHAR). It affects all command objects of this connection. Behaviour of data reader depends on Trim Fixed Char value at the moment of opening data reader. The default value is true.
UnicodeSpecifies whether dotConnect for Oracle uses UTF16 mode API calls. The default value is false.
User ID -or- UserThe Oracle login account. Leave blank if you want to use Integrated Security connections (OS authentication).
Validate ConnectionSpecifies whether to validate connections that are being got from the pool.

Example

The following example creates an OracleConnection and sets some of its properties in the connection string.

[C#] 

public void CreateOraConnection() 

    string oracleConnectionString1 = "User ID=Scott; Password=tiger; Data Source=ORA";  
    OracleConnection oracleConnection1 = new OracleConnection(oracleConnectionString1);  
    oracleConnection1.Open();  
  
    string oracleConnectionString2 =  
        "User ID=Scott; Password=tiger; Direct = true; Host=ORA; Service Name=SID; Port=1521;";  
    OracleConnection oracleConnection2 = new OracleConnection(oracleConnectionString2);  
    oracleConnection2.Open();  

[Visual Basic] 

Public Sub CreateOraConnection()
    Dim OracleConnectionString1 As String = "User ID=Scott; Password=tiger; Data Source=ORA"
    Dim OracleConnection1 As New OracleConnection(OracleConnectionString1)
    OracleConnection1.Open()

    Dim OracleConnectionString2 As String = _
        "User ID=Scott; Password=tiger; Direct = true; Host=ORA; Service Name=SID; Port=1521;"
    Dim OracleConnection2 As New OracleConnection(OracleConnectionString2)
    OracleConnection2.Open()
End Sub

See Also

OracleConnection Class  | OracleConnection Members  | Open Method

 

 


© 2002 - 2013 Devart. All Rights Reserved.