|Subject:||Application hangs when I press the Cancel button in WinSQL|
|Creation date:||7/29/09 4:21 PM|
|Last modified on:||12/11/18 3:17 PM|
WinSQL starts a new thread when a user runs a query. While it waits for the server to respond the user can click the stop button to abort, which get called from the primary thread. More specifically, WinSQL calls the SQLCancel method in the ODBC API. Some ODBC drivers block the execution when this method is called even from a different thread - they wait for the server to reply, which can take long. When this happens it appears that the application is hung since the primary thread is waiting for the server's reply.
This only occurs with certain ODBC drivers. For instance, the driver for Microsoft SQL Server does not block and therefore, the stop button returns right away.
Unfortunately, this problem in the ODBC driver makes the user believe that WinSQL is not responding. Whereas the limitation is either imposed by the driver or the database.
Note that some databases do not support aborting a running query at all. In that case the only choice you have is to terminate the connection from your database end. Terminating a connection should cause SQLCancel method to return right away, giving control back to WinSQL.