dbopen

Description

Create and initialize a DBPROCESS structure.

Syntax

DBPROCESS *dbopen(login, server)
 
LOGINREC      *login;
char                *server;

Parameters

login

A pointer to a LOGINREC structure. This pointer will be passed as an argument to dbopen. You can get one by calling dblogin.

Once the application has made all its dbopen calls, the LOGINREC structure is no longer necessary. The program can then call dbloginfree to free the LOGINREC structure.

server

The server that you want to connect to. server is the alias given to the server in the interfaces file. dbopen looks up server in the interfaces file to get information for connecting to a server.

If server is NULL dbopen looks up the interfaces entry that corresponds to the value of the DSQUERY environment variable or logical name. If DSQUERY has not been explicitly set, it has a value of “SYBASE”. (For information on designating an interfaces file, see the reference page for dbsetifile. For more information on the interfaces file itself, see the Open Client and Open Server Configuration Guide.

NoteOn non-UNIX platforms, client applications may use a method to find server address information that is different than the UNIX interfaces file. Consult your Open Client and Open Server Configuration Guide for detailed information on how clients connect to servers.

Returns

A DBPROCESS pointer if everything went well. Ordinarily, dbopen returns NULL if a DBPROCESS structure could not be created or initialized, or if your login to the server failed. When dbopen returns NULL, it generates a DB-Library error number that indicates the error. The application can access this error number through an error handler. However, if there is an unexpected communications failure during the server login process and an error handler has not been installed, the program will be aborted.

Usage


Multiple query entries in an interfaces file


Errors

The dbopen call will return NULL if any of the following errors occur. These errors can be trapped in the application’s error handler (installed with dberrhandle.)

If dbopen is called in the entry functions of a DLL, a deadlock can arise. dbopen creates operating system threads and tries to synchronize them using system utilities. This synchronization conflicts with the operating system’s serialization process.

NoteThe use of SIGALARM in a DB-Library application can cause dbopen to fail.

SYBEMEM

Unable to allocate sufficient memory.

SYBEDBPS

Maximum number of DBPROCESSes already allocated.

Note that an application can set or retrieve the maximum number of DBPROCESS structures with dbsetmaxprocs and dbgetmaxprocs.

SYBESOCK

Unable to open socket.

SYBEINTF

Server name not found in interfaces file.

SYBEUHST

Unknown host machine name.

SYBECONN

Unable to connect: Adaptive Server is unavailable or does not exist.

SYBEPWD

Login incorrect.

SYBEOPIN

Could not open interfaces file.

See also

dbclose, dbexit, dbinit, dblogin, dbloginfree, dbsetifile, dbuse