Figure 12-11 ESQL/C Connection Library Functions and Their SQL Equivalents ESQL/C for Windows Library Function Description SQL Equivalent GetConnect() Requests an explicit connection and returns a pointer to the connection information CONNECT TO '@dbservername' WITH CONCURRENT TRANSACTION SetConnect() Switches the connection to an established (dormant) explicit connection SET CONNECT TO(without the DEFAULT option) ReleaseConnect() Closes an established explicit connection DISCONNECT(without the DEFAULT, CURRENT, or ALL options)
GetConnect()
Requests an explicit connection and returns a pointer to the connection information
CONNECT TO '@dbservername' WITH CONCURRENT TRANSACTION
SetConnect()
Switches the connection to an established (dormant) explicit connection
SET CONNECT TO(without the DEFAULT option)
ReleaseConnect()
Closes an established explicit connection
DISCONNECT(without the DEFAULT, CURRENT, or ALL options)
For example, the following code fragment uses GetConnect() to establish an explicit connection to the stores7 database on the mainsrvr database server:
Connection name
Internally generated and stored in the connection handle structure for the connection
Internally generated unless CONNECT includes the AS clause; therefore, to switch to other connections, specify the AS clause when you create the connection.
Opening a database
Only establishes an explicit connection to a database server; therefore, the application must use DATABASE (or some other valid SQL statement) to open the database.
Can establish an explicit connection to a database server and open a database when provided with names of both the database server and the database
CnctHndl
The call to GetConnect() was successful, and the function has returned a connection handle for the new connection.
null pointer
The call to GetConnect() was unsuccessful.
is a connection handle returned by a previous GetConnect() call.
The call to ReleaseConnect() was successful if the function has returned a connection handle that matches the one passed to it.
is a connection handle that a previous GetConnect() call has returned.
The call to SetConnect() was successful if the function has returned a connection handle of the connection that is now dormant.
The call to SetConnect() was not successful, indicating that no explicit connection has been established.