Client-Library Supports Connection String Properties

Client-Library now supports the API routine, ct_connect_string().

ct_connect_string()

Connects to a server by specifying a connection string.

The ct_connect_string() function provides the same functionality as ct_connect(). It also provides a mechanism to set certain attributes at connection time.

Syntax

CS_RETCODE ct_connect_string(connection, connection_string, length)
CS_CONNECTION    *connection;
CS_CHAR                  *connection_string;
CS_INT                       length;

Parameters

  • connection – a pointer to a CS_CONNECTION structure. A CS_CONNECTION structure contains information about a particular client/server connection. Use ct_con_alloc to allocate a CS_CONNECTION structure.

  • connection_string – a string containing attribute names and values.

  • length – the length, in bytes, of *connection_string. If *connection_string is null-terminated, pass length as CS_NULLTERM. If connection_string is NULL, pass length as 0 or CS_UNUSED.

Return value

ct_connect returns:

Returns

Indicates

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

CS_PENDING

Asynchronous network I/O is in effect. See the Asynchronous programming section in the Open Client Client-Library/C Reference Manual.

CS_BUSY

An asynchronous operation is already pending for this connection. See the Asynchronous programming section in the Open Client Client-Library/C Reference Manual.

The connection string is a semicolon-separated string of name=value parts:
  1. Name – a case-insensitive value that can be delimited by an equal sign (=) or semicolon (;). An attribute can have multiple synonyms. For example, server and servername refer to the same attribute.
  2. Equals sign (=) – indicates the start of the value to be assigned to the Name. If there is no equals sign, the Name is assumed to be of Boolean type with a value of true.
  3. Value – a string that is terminated by a semicolon (;). Use a backslash (\) if a semicolon or another back slash is present in the value. Values can be of type boolean, integer, or string. Valid values for Boolean types are true, false, on, off, 1, and 0.
    Note: If a boolean name is present without a value, the Boolean type must be set to true.
For example:
ct_connect_string(conn, "Username=me; Password=mypassword; Servername=ASE", CS_NULLTERM);