connect

Description

Creates a connection to Adaptive Server.

Syntax

exec sql connect user_name
[identified by password] [at connection_name]
 [using server_name];

Parameters

user_name

The user name to be used when logging in to Adaptive Server.

password

The password to use to log in to Adaptive Server.

connection_name

A name that you choose to uniquely identify the Adaptive Server connection.

server_name

The server name of the Adaptive Server to which you are connecting.

Examples

Example 1

exec sql begin declare section; 
     CS_CHAR       user[32]; 
     CS_CHAR       password[32]; 
     CS_CHAR       server[90]; 
     CS_CHAR       conname[20];
 exec sql end declare section;  
 
 strcpy(user, “mylogin”); 
 strcpy(password, “mypass”);
 strcpy(server, “YOURSERVER”);
 strcpy(conname, “con_one”);
exec sql connect :user identified by :password
     using :server at :conname;

Usage

Table 10-1: How a connection is named

If this clause is used

But without

Then, the Connection Name is

at connection_name

connection_name

using server_name

at

server_name

None

DEFAULT

See also

at connection_name, exec sql, disconnect, set connection