The ODBC interface provides functions that terminate statements, transactions, and connections, and free statement (hstmt), connection (hdbc), and environment (henv) handles.
Terminating statement processing
To free resources that are associated with a statement handle, an application calls SQLFreeStmt() with the following options:
▪ SQL_CLOSE - Closes the cursor, if one exists, and discards pending results. The application can use the statement handle again later. In ODBC 3.51, SQLCloseCursor() can also be used.
▪ SQL_UNBIND - Frees all return buffers bound by SQLBindCol() for the statement handle.
▪ SQL_RESET_PARAMS - Frees all parameter buffers requested by SQLBindParameter() for the statement handle.
SQLFreeHandle() is used to close the cursor if one exists, discard pending results, and free all resources that are associated with the statement handle.
Terminating transactions
An application calls SQLEndTran() to commit or roll back the current transaction.
Terminating connections
To terminate a connection to a driver and data source, an application performs the following steps:
1 Calls SQLDisconnect() to close the connection. The application can then use the handle to reconnect to the same data source or to a different data source.
2 Calls SQLFreeHandle() to free the connection or environment handle and free all resources associated with the handle.