Possible to cancel query execution?

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Ray Mond

Possible to cancel query execution?

Post by Ray Mond » Sat 16 Jul 2005 06:41

Is is possible to cancel an executing query, like Query Analyzer does? Thanks.


Ray Mond

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Mon 18 Jul 2005 06:09

Please see TCustomMSDataSet.BreakExec description

Ray Mond

Post by Ray Mond » Mon 18 Jul 2005 15:04

How do I go about using this method? Do I create one TMSConnection, but 2 different TMSQuery components in 2 different threads, both connected to the same TMSConnection, where one runs the query and the other cancels it whenever needed?

Ray Mond

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Wed 20 Jul 2005 11:37

Not, you must use at the single thread own TMSConnection and TMSQuery. If necessary, break an execution, from another thread call BreakExec of TMSQuery. It is a seldom case when with the single component (TMSQuery) can work from several threads at the same time.

Ray Mond

Post by Ray Mond » Thu 21 Jul 2005 02:07

So it works like this?

I have a GUI app. To run a query, I create a thread with it's own TMSConnection and TMSQuery. When I want to cancel the query, I call the TMSQuery's BreakExec from my main form?

Ray Mond

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Thu 21 Jul 2005 06:13

Yes, you are absolutely right

com
Posts: 1
Joined: Mon 15 May 2006 05:18

Post by com » Mon 15 May 2006 05:44

Assuming that I can cancel executing query from main thread with BerakExec. This mean I must run query in separate thread. But now I want to have both possibilities: to cancel query, running in the separate thread and to display recordset in a grid in main thread.

The question is: how can I put recordset in main thread?

With ADO I can handle it just assigning MainThreadADODataSet.Recordset = InterruptableThreadADODataSet.Recordset;
on thread terminate.
But with SDAC I have no idea.

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Wed 17 May 2006 12:18

SDAC doesn't support such functionality.

Post Reply