Terminating a CLI application

After you have initialized your CLI application and processed transactions, you must terminate the application to properly disconnect from the data source and free resources.

Before you begin

Before terminating your application, you should have initialized your CLI application and completed processing of all transactions.

Procedure

To terminate a CLI application:

  1. Disconnect from the data source by calling SQLDisconnect().
  2. Free the connection handle by calling SQLFreeHandle() with a HandleType argument of SQL_HANDLE_DBC.

    If multiple database connections exist, repeat steps 1 - 2 until all connections are closed and connection handles freed.

  3. Free the environment handle by calling SQLFreeHandle() with a HandleType argument of SQL_HANDLE_ENV.