Product Documentation

FairCom Direct SQL for C and C++

Previous Topic

Next Topic

ctsqlConnect

Establishes a connection with a FairCom DB SQL database using DSQL.

Declaration

CTSQLRET ctsqlConnect(pCTSQLCONN hConn, CTSQLCHAR* dbname, CTSQLCHAR* username, CTSQLCHAR* password)

Description

ctsqlConnect() establishes a connection with a FairCom DB SQL database. If a connection is active, ctsqlConnect() will disconnect the current connection and try to obtain a new connection.

  • hConn the connection handle, obtained with a call to ctsqlNewConnection()
  • dbname the database name
  • username the user name to connect
  • password the user password

Note: To set SSL options, call ctsqlSetSSL before calling ctsqlConnect.

Usage

If you are remotely connecting to your server, the SQL port and DNS name need to be specified in the connection string supplied for the dbname parameter. The format is as follows:

c-treeSQLPort@DNS:DatabaseName

The defaults for FairCom DB SQL are:

  • c-treeSQLPort - 6597
  • DNS - localhost
  • DatabaseName - ctreeSQL

The resulting connection string would be: 6597@localhost:ctreeSQL

Return

ctsqlConnect() returns CTSQLRET_OK on success.

Symbolic Constant

Explanation

SQL_ERR_BADPARAM

Bad parameter specification for the statement.

SQL_ERR_NOMEM

Memory allocation failure.

See Also

ctsqlDisconnect(), ctsqlNewConnection(), ctsqlSetSSL

TOCIndex