Stoping query while opening

Stoping query while opening

Postby 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 ?
Astellia
 

Postby 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)
swierzbicki
 
Posts: 451
Joined: Wed 19 Jan 2005 09:59

Postby 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).
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Postby 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.
Astellia
 

Postby 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.
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56


Return to MySQL Data Access Components