Cicode Programming Reference > Cicode Function Categories > SQL Functions > SQLOpen

SQLOpen

Opens an SQL connection between the DB connection object specified by the function's parameter and the database defined by the connection string given before as the parameter to either SQLCreate or SQLConnect function.

Note: Currently there are certain configurations of providers, connection strings and database systems which can automatically close connections for the sake of saving the database systems' resources; for example MS SQL Server dedicated provider with activated pooling closes the connection to MS SQL Server when there is no data exchange between the client and the DB server for some predefined time. If such behaviour is observed and is not desired from the system design point of view, it can be either:
- switched off by finding and using respective attributes in the connection string (if existing and supported by DB) or
- by actively checking error codes returned from SQL CiCode functions and reconnecting by using SQLOpen if the connection is dropped.
The actual state of connections can be checked by SQLInfo with type 5.

This function is a blocking function and should not be called from a foreground task.

Syntax

SQLOpen(hSQL)

hSQL:

The handle to the DB connection object, returned from either the SQLCreate() or SQLConnect() function. The handle identifies the DB connection object where details of the associated SQL connection are stored.

Return Value

0 if success, otherwise an error code (For details call the SQLErrMsg() function)

Related Functions

SQLCreate, SQLOpen, SQLClose, SQLDispose, SQLConnect, SQLDisconnect, SQLInfo

Example

See SQLCreate.

See Also

SQL Functions

Published June 2018