AseConnection constructors

Description

Initializes an AseConnection object. The connection must then be opened before you can carry out any operations against the database.

Syntax 1

AseConnection( )

Syntax 2

AseConnection( string connectionString )

Parameters

connectionString: An Adaptive Server connection string. A connection string is a semicolon-separated list of keyword-value pairs.

Table 5-1: Connection string parameters

Property name

Description

Required

Default value

UID, UserID, User ID, User

A case-sensitive user ID required to connect to the Adaptive Server server.

Yes

Empty

PWD, Password

A case-sensitive password to connect to the Adaptive Server server.

No, if the user name does not require a password

Empty

Server, Data Source, DataSource, Address, Addr, Network Address, Server Name

The name or the IP address of the Adaptive Server server.�

Yes

Empty

Port, Server Port

The port number of Adaptive Server server.

Yes, unless the port number is specified in the Datasource

Empty

AnsiNull

Strict ODBC compliance where you cannot use “= NULL”. Instead you have to use “IsNull”. Set to 1 if you want to change the default behavior.

No

0

ApplicationName, Application Name

The name to be used by Adaptive Server to identify the client application

No

Empty.

BufferCacheSize

Keeps the Input / Output buffers in pool. Increase for very large results to boost performance

No

20

CharSet

The designated character set. The Adaptive Server ADO.NET Data Provider by default negotiates the same default character set as Adaptive Server. The default character set is ServerDefault.

No

Value of ServerDefault

ClientHostName

The name of client host passed in the login record to the server, for example: ClientHostName='MANGO'

No

Empty

ClientHostProc

The identity of client process on this host machine passed in the login record to the server, for example: ClientHostProc='MANGO-PROC'

No

Empty

CodePageType

Specifies the type of character encoding used. The valid values are ANSI and OEM.

No

ANSI

ConnectionIdleTimeout, Connection IdleTimeout, Connection Idle Timeout

The time, in seconds, that a connection can stay idle in the connection pool before the driver closes the connection. A value of 0 allows connections to stay idle for an indefinite amount of time.

No.

0

Connection Lifetime

The time, in seconds, that connections can stay open. When a client closes a connection that has reached or exceeded the defined Connection Lifetime, before the driver closes the connection instead of returning it to the connection pool. An idle connection is closed and removed from the connection pool once it reaches the defined Connection Lifetime.

The default value of Connection Lifetime is 0, which indicates that the connection can remain open for an indefinite amount of time.

No

0

CumulativeRecordCount,Cumulative Record Count,CRC

By default the driver (use provider for ADO.NET) returns the total records updated when multiple update statements are executed in a stored procedure. This count includes all updates happening as part of the triggers set on an update or an insert. Set this property to 0 if you want the driver to return only the last update count.

No

1

Database, Initial Catalog

The database to which you want to connect.

No

Empty.

DSPassword, Directory Service Password

The password used to authenticate on the LDAP server, if the LDAP server does not allow anonymous access. The password can be specified in the DSURL as well.

No

Empty.

DSPrincipal, Directory Service Principal

The user name used to authenticate on the LDAP server, if the LDAP server does not allow anonymous access. The Principal can be specified in the DSURL as well.

No

Empty.

DSURL, Directory Service URL

The URL to the LDAP server.

No

Empty.

DTCProtocol (Windows only)

Allows the driver to use either an XA protocol or OleNative protocol when using distributed transactions. See “Using Distributed Transactions”, in Chapter 4, “Adaptive Server Advanced Features.”

No

XA

EnableServerPacketSize

Allows Adaptive Server server versions 15.0 or later to choose the optimal packetsize.

No

1

EncryptPassword, EncryptPwd, Encrypt Password

Specifies if password encryption is enabled: 0 indicates password encryption is disabled, 1 indicates password encryption is enabled.

No

0

Encryption

The designated encryption. Possible values: ssl, none.

No

Empty.

FetchArraySize

Specifies the number of rows the driver retrieves when fetching results from the server.

No

25

HASession

Specifies if High Availability is enabled. 0 indicates High Availability disabled, 1 High Availability enabled.

No

0

IgnoreErrorsIfRS Pending

Specifies whether the driver is to continue processing or stop if error messages are present. When set to 1, the driver will ignore errors & continue processing the results if more results are available from the server. When set to 0, the driver will stop processing the results if an error is encountered even if there are results pending.

No

0

Language

The language in which Adaptive Server returns error messages.

No

Empty – Adaptive Server uses English by default.

LoginTimeOut, Connect Timeout, Connection Timeout

Number of seconds to wait for a login attempt before returning to the application. If set to 0 the timeout is disabled and a connection attempt waits for an indefinite period of time.

No

15

min pool size

You can force the provider to close connections to Adaptive Server so that total number of open connections hover around min pool size. The provider closes the connection on AseConnection.Close() if the number of connections in the pool are equal to min pool size.

No

20

max pool size

You can restrict the connection pool not to grow more than the specified max pool size. The provider will throw an AseException on AseConnection.Open() if this limit is reached.

No

100

NamedParameters

Set to false if you intend to use parameter markers instead of named parameters. Example with named parameters the SQL will look like SELECT * from titles where title_id = @title_id�.The same SQL with parameter markers will look like SELECT * from titles where title_id = ?.

No

true

PacketSize, Packet Size

The number of bytes per network packet transferred between Adaptive Server and the client.

No

512

Ping Server

Set to false if you do not want the provider to verify that the connection is valid before it uses it from the connection pool.

No

true

pooling

To disable connection pooling set to false.

No

true

QuotedIdentifier

Specifies if Adaptive Server treats character strings enclosed in double quotes as identifiers: 0 indicates do not enable quoted identifiers, 1 indicates enable quoted identifiers.

No

0

RestrictMaximum PacketSize

If the you have memory constraints when EnableServerPacketSize is set to 1, then set this property to an int value in multiples of 512 to a maximum of 65536.

No

0

SecondaryPort, Secondary Port, Secondary Server Port

The port number of the Adaptive Server server acting as a failover server in an active-active or active-passive setup.

Yes, if HASession is set to 1, unless the port number is specified in the Secondary DataSource.

Empty.

SecondaryServer, Secondary Data Source, Secondary DataSource, Secondary Server, Secondary Address, Secondary Addr, Secondary Network Address

The name or the IP address of the Adaptive Server acting as a failover server in an active-active or active-passive setup.�“Secondary Data Source” can be: SecondaryServer:SecondaryPort or SecondaryServer, SecondaryPort.

Yes, if HASession is set to 1.

Empty.

SQL Initialization String, SQLInitializationString, SQL Init String , SQLInitString, Initialization String, InitializationString

Defines a space-separated list of commands that is passed to database servers and executed immediately after connection. The commands must be SQL commands that are not used to query results.

No

Empty

TextSize

The maximum size of binary or text data in bytes that will be sent to or received from Adaptive Server, for example: TextSize=64000 sets this limit to 64K bytes.

No

Empty. Adaptive Server default is 32K.

TightlyCoupled Transaction (Windows only)

When using distributed transactions, if you are using two DSNs which connect to the same Adaptive Server server, set this to 1. See “Using Distributed Transactions”, in Chapter 4, “Adaptive Server Advanced Features.”

No

0

TrustedFile

If Encryption is set to ssl, this property should be set to the path to the Trusted File.

No

Empty

UseCursor, Use Cursor

Specifies whether cursors are to be used by the driver. 0 indicates do not use cursors and 1indicates use cursors.

No

0

NoteData Source, DataSource, Secondary Data Source, Secondary DataSource are special keywords. In addition to being the server name, they can also be formatted as

DataSource=servername,port

or

DataSource=servername:port

For example, DataSource=gamg:4100 sets the server name to “gamg” and the port to “4100.” In this case, the Port keyword would not be needed in the connection string.

Example

The following statement initializes an AseConnection object for a connection to a database named “policies” running on an Adaptive Server database server named “HR-001.” The connection uses a user ID of “admin” with a password of “money.”

"Data Source='HR-001';
Port=5000; UID='admin';
PWD='money';
Database='policies';"