Skip to content

Latest commit

 

History

History
22 lines (19 loc) · 1.36 KB

freeing-a-statement-handle-odbc.md

File metadata and controls

22 lines (19 loc) · 1.36 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords
Freeing a Statement Handle ODBC
Freeing a Statement Handle ODBC
David-Engel
davidengel
01/19/2017
sql
connectivity
conceptual
statement handles [ODBC]
handles [ODBC], statement
freeing statement handles [ODBC]

Freeing a Statement Handle ODBC

As mentioned earlier, it is more efficient to reuse statements than to drop them and allocate new ones. Before executing a new SQL statement on a statement, applications should be sure that the current statement settings are appropriate. These include statement attributes, parameter bindings, and result set bindings. Generally, parameters and result sets for the old SQL statement need to be unbound (by calling SQLFreeStmt with the SQL_RESET_PARAMS and SQL_UNBIND options) and rebound for the new SQL statement.

When the application has finished using the statement, it calls SQLFreeHandle to free the statement. After freeing the statement, it is an application programming error to use the statement's handle in a call to an ODBC function; doing so has undefined but probably fatal consequences.

When SQLFreeHandle is called, the driver releases the structure used to store information about the statement.

SQLDisconnect automatically frees all statements on a connection.