SQLConnection in another thread

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
YaVitaly
Posts: 1
Joined: Wed 24 Dec 2014 08:29

SQLConnection in another thread

Post by YaVitaly » Wed 24 Dec 2014 09:03

Hello,

I have so slow query and I tried to execute it in additional thread. The main reason of it - have a possibility to terminate new thread and interrupt query execuion. I created additional TSQLConnection and additional SQLDataSet into the thread. It works fine when query executes successfully, but if i try to close connection (or delete connection, or delete query) while executing query I got an error:
Project raised exception class EAssertionFailed with message 'TOLEDBCommand.Destroy - interfaces not released (2)

The questions are: Is it possible to cancel query execution? How can I do it? Is there another way to execute slow queries and cancel it?

I use RadStudio XE3 (C++ builder) and Devart DBExpress driver for SQL Server 6.3.5

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: SQLConnection in another thread

Post by azyk » Fri 26 Dec 2014 11:37

dbExpress doesn't support such a functionality. As an option, you can use the functionality implemented in the TMSSQL.BreakExec method in SDAC. This method is designed to stop execution of SQL query (as well as from another thread), during its execution. More details about this method are available in our documentation: http://www.devart.com/sdac/docs/index.h ... exec().htm .

Note: a sample of using BreakExec in SDAC is available in the SDACDemo demo project (the source code of the project is for Delphi). SDACDemo is in the "Demos\SDACDemo\" folder relatively to the SDAC demo projects installation path.

Post Reply