Stoping query while opening

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Astellia

Stoping query while opening

Post by Astellia » Tue 02 Aug 2005 09:31

I tried to stop very long time executing query, can someone help me ?

I execute "query->Open()" in a thread and "Query->Close()" in an other.
That causes an abnormal termination exception and clos the application.

Is ther a simple way with myDac components to do this ?

swierzbicki
Posts: 451
Joined: Wed 19 Jan 2005 09:59

Post by swierzbicki » Tue 02 Aug 2005 09:42

I'm not sure there is a simple solution arround here.
It will be "safer" to kill your mySQL connection (check MySQL doc for SQL syntax). After killing your current connection you will get an exception (something like lost connection to mysql server). Try to Catch this exception and either hide it or display it (in a memo comp or something similar)

But this solution is somehow risky ! you can get the server crazy, specially if using transaction (after killing the connection, mysql will do some roolback job)

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

Post by Ikar » Tue 02 Aug 2005 10:38

Yes, the way suggested by swierzbicki will work. You need an additional connection and call TMyServerControl.KillProcess(MainConnection.ThreadId).

Astellia

Post by Astellia » Tue 02 Aug 2005 15:43

I tried this solution (kill connection and catching except.) but the application become very unstable.

I don't know what is MainConnection in this sample. Is it a TMyConnection ? ThreadId is not a member ...
I used MyDac VCL version 2.

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

Post by Ikar » Wed 03 Aug 2005 11:13

MyDAC 2 doesn't have MyConnection.ThreadId property.
So there is no possibility to know Id of connection that executes a specified query.

Unlikely you can do it with MyDAC 2.

Post Reply