Documentation

ODBC Driver Guide

Previous Topic

Next Topic

Done

When an application and/or process has completed operations with the database, it must release resources by disconnecting from the database engine.

Below is the code for Done():

/*

* Done()

*

* This function handles the housekeeping of closing connection and

* freeing of associated memory

*/

void Done(void)

{

RETCODE rc;

printf("DONE\n");

/* free statement handle */

if ((rc = SQLFreeHandle(SQL_HANDLE_STMT, hStmt)) != SQL_SUCCESS)

Handle_Error(SQL_HANDLE_DBC, hDbc, "SQLFreeHandle(SQL_HANDLE_STMT)");

/* disconnect from server */

printf("\tLogout...\n");

if ((rc = SQLDisconnect(hDbc)) != SQL_SUCCESS)

Handle_Error(SQL_HANDLE_DBC, hDbc, "SQLDisconnect()");

/* free connection handle */

if ((rc = SQLFreeHandle(SQL_HANDLE_DBC, hDbc)) != SQL_SUCCESS)

Handle_Error(SQL_HANDLE_ENV, hEnv, "SQLFreeHandle(SQL_HANDLE_DBC)");

/* free environment handle */

if ((rc = SQLFreeHandle(SQL_HANDLE_ENV, hEnv)) != SQL_SUCCESS)

Handle_Error(0, NULL, "SQLFreeHandle(SQL_HANDLE_ENV)");

}

TOCIndex