Contents Index Connecting to a data source using a logon dialog box Data types

iAnywhere Solutions ODBC Drivers
  iAnywhere Solutions ODBC Driver for Sybase Adaptive Server Enterprise

Connecting to a data source using a connection string


If your application requires a connection string to connect to a data source, you must specify the data source name that tells the driver which section in the system information to use for the default connection information. Optionally, you may specify attribute=value pairs in the connection string to override the default values stored in the system information. These values are not written to the system information.

You can specify either long or short names in the connection string. The connection string has the form:

DSN=data_source_name[;attribute=value[;attribute=value]...]

An example of a connection string for Adaptive Server Enterprise is:

DSN=SYS11 TABLES;SRVR=QESRVR;DB=PAYROLL;UID=JOHN;PWD=XYZZY

The following table gives the long and short names for each attribute, as well as a description. To configure a data source in the UNIX environment, you must edit the system information file. This file accepts only long names for attributes.

For information about editing this file, see Quick start for UNIX.

The defaults listed in the table are initial defaults that apply when no value is specified in either the connection string or in the data source definition in the system information. If you specified a value for the attribute when configuring the data source, that value is the default.

Most settings can be left at their default values. For a list of key driver settings when using MobiLink, see Key driver settings for MobiLink.

Attribute Description
AppCodePage (ACP) AppCodePage has been replaced by IANAAppCodePage (IACP). See below.
ApplicationName (APP) The name used by Sybase to identify your application.
ApplicationUsingThreads (AUT) ApplicationUsingThreads={0|1}. Ensures that the driver works with multi-threaded applications.

When set to 1 (the initial default), the driver is thread-safe.

When using the driver with single-threaded applications, you can set this option to 0 to avoid additional processing required for ODBC thread-safety standards.

ArraySize (AS) The number of rows the driver retrieves from the server for a fetch. This is not the number of rows given to the user. This increases performance by reducing network traffic.

The initial default is 50 rows.

Charset (CS) The name of a character set. This character set must be installed on the Sybase server. The default is the setting on the Sybase server. For this driver to support Unicode, this attribute must be set to UTF-8. Refer to the Sybase server documentation for a list of valid character set names.
CursorCacheSize (CCS) The number of connections that the connection cache can hold. To set the connection cache, you must set the SelectMethod attribute to 1. Increasing the connection cache may increase performance of some applications but requires additional database resources.

The initial default is 1 (one cursor).

Database (DB) The name of the database to which you want to connect.
DataSourceName (DSN) A string that identifies a single connection to a Sybase database. Examples include "Accounting" or "Sys10-Serv1."
DefaultLongDataBuffLen (DLDBL) An integer value that specifies, in 1024-byte multiples, the maximum length of data fetched from a TEXT or IMAGE column. You will need to increase this value if the total size of any long data exceeds 1 MB.

The default is 1024.

DistributedTransactionModel (DTM) DistributedTransactionModel={XA Protocol0 21| Native OLE}. Determines which model is used for distributed transaction support. The initial default is XA Protocol.

Leave this option at the default setting.

EnableDescribeParam (EDP) EnableDescribeParam={0|1}. Determines whether the ODBC API function SQLDescribeParam is enabled.

When set to 0 (the initial default), SQLDescribeParam is disabled.

When set to 1, SQLDescribeParam is enabled, which allows an application to describe parameters in SQL statements and in stored procedure calls. To use this option, OptimizePrepare must be set to 0 or 1, and the SQL statement must not include long parameters. This attribute should be set to 1 when using Microsoft Remote Data Objects (RDO) to access data.

EnableQuotedIdentifiers (EQI) EnableQuotedIdentifiers={0|1}. Enables quoted identifiers.

When set to 0 (the initial default), quoted identifiers are disabled.

When set to 1, quoted identifiers are enabled.

FailoverNetworkAddress (FNA) Specifies the address of the High Availability (HA) Failover server to be used in the event of a connection loss. The driver detects the dropped connection and automatically reconnects to the HA Failover server specified by this attribute. This attribute is valid only for Sybase version 12 or higher servers that have the High Availability Failover feature enabled.

See the description of the Network Address attribute for an explanation of valid values.

IANAAppCodePage (IACP) Valid values for this attribute are listed in Values for IANAAppCodePage Connection String Attribute. The code page that you specify must be the same as the code page used by your application. The driver on UNIX determines the value of the application's code page by checking for an IANAAppCodePage value in the following order:
  • In the connection string

  • In the DataSource section of the system file (odbc.ini)

  • In the ODBC section of the system file (odbc.ini)

If no IANAAppCodePage value is found, the driver uses the default value of 4 (ISO 8859-1 Latin-1).

NOTE: The IANAAppCodePage connection string attribute replaces the AppCodePage connection string attribute in earlier versions of Connect for ODBC. The drivers are backwardly compatible with the AppCodePage attribute, but you must now use the IANAAppCodePage attribute.

InitializationString (IS) InitializationString={Sybase set commands;...}. Supports the execution of Sybase commands at connect time. Multiple commands must be separated by semicolons.
InterfacesFile (IF) Specifies the path name of the Interfaces file. If you do not specify a value for this attribute, but specify a value for the Interfaces File Server Name attribute, the driver looks for the path name of the Interfaces file in the Registry under HKEY_LOCAL_MACHINE\SOFTWARE\DataDirect\InterfacesFile. If this Registry value is empty, then the driver attempts to open the SQL.INI file found in the same directory as the driver and use it as the Interfaces file.
InterfacesFileServer Name (IFSN) Specifies the name of the section in the Interfaces file that contains the network connection information for the Sybase server you want to access. The section name typically is the host name of the server that contains the Sybase Server you want to access.
Language (LANG) The national language. This language must be installed on the Sybase server.

The initial default is English.

LogonID (UID) The default logon ID used to connect to your Sybase database. This ID is case-sensitive. A logon ID is required only if security is enabled on your database. If so, contact your system administrator to get your logon ID.
NetworkAddress (NA) The network address depends on which network protocol is chosen under Network Library Name and on the Sybase server. If you have chosen Winsock, specify an IP address as follows: "servername-or-IP-address, port-number". For example, if your network supports named servers, you may specify an address such as "Sybaseserver, 5000". You may also specify the IP address directly such as "199.226.224.34, 5000".

If you have chosen NamedPipes as the network protocol, you must specify the pipe address of the server. For example, "\\machine1\sybase\pipe\query".

NetworkLibraryName (NLM) NetworkLibraryName={Winsock|NamedPipes}. The name of the network library. This specifies which network protocol to use.

The initial default is Winsock.

This option has no effect on UNIX; on UNIX, TCP/IP is used.

OptimizePrepare (OP) OptimizePrepare={0|1|2|3}. Determines whether stored procedures are created on the server for calls to SQLPrepare.

For use with MobiLink, set this parameter to 2.

When set to 0, stored procedures are created for every call to SQLPrepare. This setting can result in decreased performance when processing statements that do not contain parameters.

When set to 1 (the initial default), the driver creates stored procedures only if the statement contains parameters. Otherwise, the statement is cached and run directly at the time of SQLExecute.

When set to 2, stored procedures are never created. The driver caches the statement, executes it directly at the time of SQLExecute, and reports any syntax or similar errors at the time of SQLExecute.

When set to 3, stored procedures are never created. This is identical to value 2 except that any syntax or similar errors are returned at the time of SQLPrepare instead of SQLExecute. Use this setting only if you must have syntax errors reported at the time of SQLPrepare.

PacketSize (PS) When set to -1, the driver computes the maximum allowable packet size on the first connect to the data source and saves the value in the system information.

When set to 0 (the initial default), the driver uses the default packet size as specified in the Sybase server configuration.

When set to x, an integer from 1 to 1024, the driver uses a packet size represented by x times 512 bytes. For example, PacketSize=6 means to set the packet size to 6 * 512 bytes (3072 bytes).

To take advantage of this connection attribute, you must configure the Sybase server for a maximum network packet size greater than or equal to the value you specified for PacketSize. For example:

sp_configure "maximum network packet size", 5120
reconfigure
Restart Sybase Server
NOTE: The ODBC specification specifies a connect option, SQL_PACKET_SIZE, that offers this same functionality. To avoid conflicts with applications that may set both the connection string attribute and the ODBC connect option, they have been defined as mutually exclusive. If PacketSize is specified, you will receive a message "Driver Not Capable" if you attempt to call SQL_PACKET_SIZE. If you do not set PacketSize, then application calls to SQL_PACKET_SIZE are accepted by the driver.
Password (PWD) A case-sensitive password.
RaiseErrorPositionBehavior (REPB) RaiseErrorPositionBehavior={0|1}. Specifies when the error is returned and where the cursor is positioned when raiserror is encountered.

When set to 0 (the initial default), raiserror is handled separately from surrounding statements. The error is returned when raiserror is processed via SQLExecute, SQLExecDirect, or SQLMoreResults. The result set is empty.

When set to 1 (MS compatible), raiserror is handled with the next statement. The error is returned when the next statement is processed and the cursor is positioned on the first row of subsequent result set. This could result in multiple raiserrors being returned on a single execute.

SelectMethod (SM) SelectMethod={0|1}. Determines whether database cursors are used for SELECT statements.

When set to 0 (the initial default), database cursors are used. In some cases performance degradation can occur when performing large numbers of sequential SELECT statements because of the amount of overhead associated with creating database cursors.

When set to 1, SELECT statements are run directly without using database cursors, and the data source is limited to one active statement.

To set the connection cache, SelectMethod must be set to 1. For more information, see CursorCacheSize, above.

TightlyCoupled DistributedTransactions (TCDT) TightlyCoupledDistributedTransactions={0|1}. Determines whether the driver uses tightly coupled distributed transactions when connected to an Adaptive Server Enterprise version 12 or higher database. When set to 1 (the initial default), the driver uses this type of transaction and multiple connections within the same distributed transaction do not obey each other's locks.

When set to 0, the overall performance of the driver is better, but multiple connections within the same distributed transaction may hang each other because the connections do not obey each other's locks.

This attribute is valid only when the driver is enlisted in a distributed transaction or when it is connected to a Sybase version 12 or higher database. Otherwise, this attribute is ignored.

WorkstationID (WKID) The workstation ID used by the client.
XAOpenStringParameters (XAOSP) Specifies trace file names. Use the syntax -Ltrace_filename, where trace_filename specifies the name of two trace files that will be created. The first trace file will trace all XA call activities and will be named exactly as you specified. The second trace file will contain tracing of any enlistment and unenlistment procedures and will be named as you specified with a "driver" extension. For example, if you specify XAtrace as the file name, the driver will create two trace files-XAtrace and XAtrace.driver.

Contents Index Connecting to a data source using a logon dialog box Data types