End ODBC functions

The last procedure that must be completed before ending an ODBC application is to free the resources and memory allocated by the application. This must be done so that they are available when the application is run the next time.

SQLFreeStmt
Stops processing associated with a specific statement handle.
rc = SQLFreeStmt(hstmt, option); // option can be SQL_CLOSE, SQL_RESET_PARAMS. or SQL_UNBIND
SQL_CLOSE
Closes the cursor associated with the statement handle, and discards all pending results. Alternately, you can use SQLCloseCursor.
SQL_RESET_PARAMS
Releases all common buffers that are bound by SQLBindParameter.
SQL_UNBIND
Releases all common buffers that are bound by SQLBindCol.
SQLFreeHandle with SQL_HANDLE_STMT as the handle type
Frees all resources for this statement.
  rc = SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
SQLDisconnect
Closes the connection associated with a specific connection handle.
rc = SQLDisconnect(hdbc);
SQLFreeHandle with SQL_HANDLE_DBC as the handle type
Releases connection handle and frees all memory associated with a connection handle.
rc = SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
SQLFreeHandle with SQL_HANDLE_ENV as the handle type
Frees environment handle and releases all memory associated with the environment handle.
rc = SQLFreeHandle(SQL_HANDLE_ENV, henv);