Exiting a Windows-based Application

For Windows, your application must make an additional call to free all memory associated with your application. More than one application can reference DB-Library for Visual Basic at the same time. To avoid conflicts between these applications, DB-Library for Visual Basic allocates memory to store information identifying each application. When you exit a DB-Library for Visual Basic application, you must call SqlWinExit to release this memory and make it available to other applications.

The following program fragment illustrates the use of SqlWinExit:

SUB Quit_Click()
   'Close and free all SQL Server connections.
   SqlExit

   'Release memory allocated for VBSQL.
   SqlWinExit

   'End VBSQL application.
   END
END SUB

Typically, Windows-based applications include an Exit or Quit menu option with the File menu. The Visual Basic event procedure associated with the Exit menu option must include calls to both SqlExit and SqlWinExit to close all connections and release memory allocated to the application.