Skip to content

Latest commit

 

History

History
34 lines (29 loc) · 2.11 KB

disconnecting-from-a-data-source.md

File metadata and controls

34 lines (29 loc) · 2.11 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords
Disconnecting from a Data Source
Disconnecting from a Data Source
markingmyname
maghan
03/03/2017
sql
native-client
reference
ODBC data sources, connections
data sources [SQL Server Native Client]
disconnecting [ODBC]
ODBC applications, disconnecting
SQLDisconnect function
ODBC applications, data sources
connections [SQL Server Native Client]
SQLFreeHandle function
ODBC data sources, disconnecting
SQL Server Native Client ODBC driver, data sources
ODBC functions
SQL Server Native Client ODBC driver, connections

Disconnecting from a Data Source

[!INCLUDESQL Server Azure SQL Database Synapse Analytics PDW]

When an application has finished using a data source, it calls SQLDisconnect. SQLDisconnect frees any statements that are allocated on the connection and disconnects the driver from the data source. After disconnecting, the application can call SQLFreeHandle to free the connection handle. Before exiting, an application also calls SQLFreeHandle to free the environment handle.

After disconnecting, an application can reuse the allocated connection handle, either to connect to a different data source or reconnect to the same data source. The decision to remain connected instead of disconnecting and reconnecting later requires that the application writer consider the relative costs of each option. Connecting to a data source and remaining connected can be relatively costly, depending on the connection medium. In making a trade-off, the application must also make assumptions about the probability and timing of additional operations on the same data source. An application may also have to use more than one connection.

See Also

Communicating with SQL Server (ODBC)