dotConnect for DB2 Documentation
Devart.Data.DB2 Namespace / DB2Connection Class / ConnectionString Property
Example

In This Topic
    ConnectionString Property (DB2Connection)
    In This Topic
    Gets or sets the string used to open a DB2 connection.
    Syntax
    'Declaration
     
    Public Overrides Property ConnectionString As String
    public override string ConnectionString {get; set;}

    Property Value

    The connection string that includes the parameters needed to establish the initial connection. The default value is an empty string ("").
    Remarks
    When ConnectionString property is assigned a value, connection closes. 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. DB2Connection 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 "User Id=test", and then reset the connection string to "Data Source=localhost", the UserId property is no longer set to test.

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

    The ConnectionString is similar to an OLE DB connection string. Values may be delimited by single or double quotes, (for example, name='value' or name="value"). Either single or double quotes may be used within a connection string by using the other delimiter, for example, name="value's" or name= 'value"s', but not name= 'value's' or name= ""value"". All blank characters, except those placed within a value or within quotes, are ignored. Keyword value pairs must be separated by a semicolon (;). If a semicolon is part of a value, it also must be delimited by quotes. No escape sequences are supported. The value type is irrelevant. Names are not case sensitive. Arguments names may occur only once in the connection string.

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

    Name Description
    Authentication A string representing the type of authentication to be used. The default value is "SERVER". Acceptable values are: SERVER, SERVER_ENCRYPT, DATA_ENCRYPT, KERBEROS, GSSPLUGIN, CERTIFICATE.
    CaptureMode Determines if dynamically executed statements are captured for client optimization using pureQuery. Can be "on" or "off". The default value is "off".
    CLISchema The name of the schema to be used with the db2ocat tables. This value is not set by default.
    ClientAccountingString The client accounting string. The default value is an empty string ("").
    ClientApplicationName The client application name. The default value is an empty string ("").
    ClientApplicationName The client application name. The default value is an empty string ("").
    ClientEncAlg Determines whether the AES encryption is used. Set this parameter to "AES" in order to use it. In such case the Authentication parameter will be considered equal to "SERVER_ENCRYPT".
    ClientUserID The string containing the client user ID.
    ClientWorkstationName The name of the client workstation. The default value is an empty string ("").
    CodePage The connection Encoding code page identifier.
    Collection The collection name, which is the qualifier of the package name (collection.rootPkgName).
    ConcurrentAccessResolution The concurrent access resolution to use. See DB2ConnectionStringBuilder.ConcurrentAccessResolution for more information.
    ConnStrPwdEncrypt Determines whether the password specified in the connection string is stored encrypted in memory.
    ConnectNodeNumber The database partition server to connect to.
    Connect Timeout -or- Connection Timeout The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error. The default value is 15.
    Connection Lifetime Number of seconds for connection to live.
    ConvertToLong Determines whether varchar inputs should be reported as long varchar.
    CurrentPackageSet The schema name for selecting the package to use for subsequent SQL statements. If this parameter is set, the SET CURRENT PACKAGESET statement is executed each time when connecting. This statement specifies the schema name for selecting the package to use for subsequent SQL statements.
    Current Schema The default user ID to use as the owner for unqualified SQL objects.
    Data Source -or- Host -or- Server The name or IP address of host of DB2 database to which to connect.
    Database The name of the database. If this parameter is not specified, it is assumed that name of the database is same as user name.
    DB2Explain The default user ID to use as the owner for unqualified SQL objects.
    DBName The database name. This parameter is only used when connecting to DB2 for z/OS and OS/390, and only if (base) table catalog information is requested by the application.
    Default Command Timeout The default time in seconds to wait while trying to execute a command before terminating the attempt and generating an error. 0 indicates no limit.
    Default Fetch All Default value of the Devart.Data.DB2.DB2Command.FetchAll property of DB2Command instances, created via the CreateCommand method. If the FetchAll mode is enabled, DB2DataReader object retrieves all the querried data from the server on execution.
    DelimIdent Specifies whether any string within double quotes (") is treated as an identifier, and any string within single quotes (') is treated as a string literal.
    DisableCursorHold Determines the effect of a transaction completion on open cursors. Default value is false - the cursors are not destroyed after completing the transaction.
    Enlist Determines whether the connection is automatically enlisted in the current distributed transaction. The default value is true.
    EnsureDefaultDFRM Specifies whether the Open method will attempt to explicitly set the rounding mode to ROUND_HALF_EVEN. If true the Open method will attempt to explicitly set the rounding mode to ROUND_HALF_EVEN. If the database rounding mode is not ROUND_HALF_EVEN, then the Open() call will throw a DB2RoundingModeException but the connection will remain open. Default value is false.
    ExecutionMode Determines whether previously captured statements should be executed statically for client optimization using pureQuery. Can be either "static" or "dynamic". "static" means that statements that are captured and packaged in the database are executed statically, statements that have not been captured will be executed dynamically. "dynamic" means that all statements will be processed dynamically.
    FitHighPrecisionType The type of precision to use. For the list of supported values and their meaning see DB2FitHighPrecisionType.
    Graphic Specifies if GRAPHIC (double-byte character) is returned as a supported SQL data type and what unit is used to report GRAPHIC column length. Can be an integer value from 0 to 3. Default value is 0. This means that GRAPHIC is not returned as a supported SQL data type, and the reported length of GRAPHIC columns equals the maximum number of DBCS characters in the column. 1 means that GRAPHIC is returned as a supported SQL data type, and the reported length of GRAPHIC columns equals the maximum number of DBCS characters in the column. 2 means that GRAPHIC is not returned as a supported SQL data type, and the reported length of GRAPHIC columns equals the maximum number of bytes in the column. 3 means GRAPHIC is returned as a supported SQL data type, and the reported length of GRAPHIC columns equals the maximum number of bytes in the column.
    HostVarParameters Determines whether the support for host variables is enabled.
    Instance The instance name for a local IPC connection.
    Interrupt An integer value (0, 1, or 2) representing the interrupt processing mode. 0 disables interrupt processing. 1 means that interrupts supported are sent, otherwise the connection is closed. 3 means that interrupts drop the connection. Default value is 1.
    Isolation Level The isolation level for the connection. The default value is "SQL_TXN_READ_COMMITTED". The supported values are: SQL_TXN_READ_UNCOMMITTED - Read Uncommitted (Uncommitted read), SQL_TXN_READ_UNCOMMITTED - Read Uncommitted (Uncommitted read), SQL_TXN_REPEATABLE_READ - Repeatable Read (Read Stability), and SQL_TXN_SERIALIZABLE - Serializable (Repeatable read).
    MapDate Defines whether the DATE types should be reported as a different data type. Can be an integer value (0, 1, or 2). Default value is 0, which means that no mapping is performed, and DATE is reported as DATE. 1 means that DATE is reported as SQL_CHAR. 2 means that DATE is reported as SQL_WCHAR.
    MapTimestamp Defines whether the TIMESTAMP types should be reported as a different data type. Can be an integer value (0, 1, or 2). Default value is 0, which means that no mapping is performed, and TIMESTAMP is reported as TIMESTAMP. 1 means that TIMESTAMP is reported as SQL_CHAR. 2 means that TIMESTAMP is reported as SQL_WCHAR.
    Max Pool Size The 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 Size The minimum number of connections allowed in the pool. The default value is 0.
    Password The password for the DB2 login account.
    Persist Security Info 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.
    Pooling If true, by default, the DB2Connection object is drawn from the appropriate pool or is created and added to the appropriate pool.
    ProgramId User-defined character string, that associates an application with a connection. The string can be of up to 80 bytes.
    ProgramName The user-defined or default application name. By default, the first 20 bytes of the executable file name are used.
    PureQueryXML The file name and path of the capture file.
    RetrieveXmlInBinaryFormat Determines whether the XML data should be retrieved in a binary format.
    RetryParameterBindingOnError If parameters are defined with an incorrect datatype, this will result in an error. When this property is set to true, the describe information is used to attempt to determine the correct datatype for the parameter and the statement is re-executed. Setting RetryParameterBindingOnError to true will preserve this functionality. However, this may decrease performance, so it is recommended to set it to false and define parameters correctly.
    RootPkgName The package identifier for the package name (collection.rootPkgName) to be used by pureQuery when ExecutionMode is set to static.
    SchemaList The list of schemas to use. The schema names in the list are case-sensitive, must be delimited with single quotes, and separated by commas. The maximum length of the string is 256 characters.
    Security If you want to enable SSL, set this parameter to SSL.
    Server The host and port to connect to, separated with a colon. For example, "db2server:5000". Port may be omitted.
    ServerType The data server type to connect to. Can be "UNIDATA" or "UNIVERSE". The default value is an empty string ("").
    SessionTimeZone The time zone at session level on the server. The range of valid value is -12:59 to +14:00.
    SSLClientKeystash The name of the SSL stash file used for an SSL connection. Must be specified together with the SSLClientKeystoredb connection string parameter in case the Security parameter is set to "SSL". The SSL stash file stores an encrypted password to the key database file.
    SSLClientKeystoredb The name of the SSL key database file used for an SSL connection. Must be specified together with the SSLClientKeystash connection string parameter in case the Security parameter is set to "SSL".
    StatementConcentrator Determines whether statement concentrator literals are enabled. Can be "Off" or "Literals". If this parameter is not specified, the behaviour is determined by the server configuration.
    StaticLatch Determines whether to enable static blocking.
    SysSchema An alternative schema to be searched.
    TableType The list of table types, which must be available via the connection. Acceptable values are: TABLE, ALIAS, VIEW, INOPERATIVE VIEW, SYSTEM TABLE, SYNONYM. You may specify any number of the values. They must be delimited with single quotes, separated by commas, and in upper case.
    TargetPrincipal The fully qualified Kerberos principal name of the DB2 instance owner for a target server. Used when the Authentication connection string parameter is set to "KERBEROS".
    TraceFile The name of a file to which all the connection trace information is written. If the file specified does not exist, then it will be created; otherwise, the new trace information will be appended to the end of the file. However, the path to the file must exist. If the filename given is invalid or if the file cannot be created or written to, no trace will occur and no error message will be returned. It is not recommended to use tracing in a multithreaded application, because all the threads will write to the same output file, and the output will be hard to decipher.
    Transaction Scope Local If 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.
    TrustedContextSystemPassword The password for the SYSTEM AUTHID of the trusted context.
    TrustedContextSystemUserID The trusted context SYSTEM AUTHID for the connection.
    User ID -or- User The DB2 login account.
    Validate Connection Specifies whether to validate connections that are being got from the pool.
    WalletID The encryption key wallet ID for U2 Data Server.
    WalletPwd The encryption key wallet password for U2 Data Server.
    Example
    The following example creates a DB2Connection and sets some of its properties in the connection string.
    public void CreateDB2Connection()
    {
      string myConnString1 = 
         "user id=db2admin;server=db2;database=SAMPLE;";
      DB2Connection db2Connection1 = new DB2Connection(myConnString1);
      db2Connection1.Open();
    }
    Public Sub CreateDB2Connection()
      Dim myConnString1 As String = _
          "user id=db2admin;server=db2;database=SAMPLE;"
      Dim db2Connection1 As New DB2Connection(myConnString1)
      db2Connection1.Open()
    End Sub
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also