First we need to open a connection to a database by providing the FairCom Database Engine with a user name, password and the database name.
Below is the code for Initialize():
/*
* Initialize()
*
* Perform the minimum requirement of logging onto the c-tree Server
*/
void Initialize(void)
{
CTSQLRET rc;
printf("INIT\n");
/* allocate connection handle */
if ((hConn = ctsqlNewConnection()) == NULL)
Handle_Error("ctsqlNewConnection()");
/* allocate command handle */
if ((hCmd = ctsqlNewCommand(hConn)) == NULL)
Handle_Error("ctsqlNewCommand()");
/* connect to server */
printf("\tLogon to server...\n");
if ((rc = ctsqlConnect(hConn, "ctreeSQL", "admin", "ADMIN")) != CTSQLRET_OK)
Handle_Error( "ctsqlConnect()");
/* enable autocommit */
if ((rc = ctsqlSetAutoCommit(hConn, CTSQL_TRUE)) != CTSQLRET_OK)
Handle_Error( "ctsqlSetAutoCommit()");
}