BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Cancel TQuery

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (Desktop)
View previous topic :: View next topic  
Author Message
Robert den Holder
Guest





PostPosted: Mon Dec 19, 2005 10:17 am    Post subject: Cancel TQuery Reply with quote



Hello,

is there a way to cancel a TQuery?

I wan't to show a dialogbox when a query is executed. When the user clicks
the cancel-button, I want the query to stop.
Now I use the "active"-property to execute a query, but that one is
blocking.

Thanks in advance,

Robert.


Back to top
Mike Shkolnik
Guest





PostPosted: Mon Dec 19, 2005 11:40 am    Post subject: Re: Cancel TQuery Reply with quote



You may run the query in thread and terminate the thread by Cancel click

As alternative, you may use the BDE-callbacks but be sure that your
db-server/driver supports this feature.

--
With best regards, Mike Shkolnik
EMail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
http://www.scalabium.com

"Robert den Holder" <robert.den.holder (AT) _NOSPAM_tpa (DOT) nl> wrote

Quote:
Hello,

is there a way to cancel a TQuery?

I wan't to show a dialogbox when a query is executed. When the user clicks
the cancel-button, I want the query to stop.
Now I use the "active"-property to execute a query, but that one is
blocking.

Thanks in advance,

Robert.





Back to top
Don Locke
Guest





PostPosted: Mon Dec 19, 2005 1:48 pm    Post subject: Re: Cancel TQuery Reply with quote



If you just want it to stop, use Query->Close();
Don
Back to top
Jayme Jeffman Filho
Guest





PostPosted: Tue Dec 20, 2005 5:40 pm    Post subject: Re: Cancel TQuery Reply with quote

Hello Don,

Have you ever done it this way ? I thought that the Open method could not be
interrupted, because there is no any "middle" event while the server is
parsing or executing the query. Can you explain how it works ?

Jayme.


"Don Locke" <dgnospamlocke (AT) comcast (DOT) net> escreveu na mensagem
news:43a6b9ea$1 (AT) newsgroups (DOT) borland.com...
Quote:
If you just want it to stop, use Query->Close();
Don



Back to top
Don Locke
Guest





PostPosted: Tue Dec 20, 2005 6:40 pm    Post subject: Re: Cancel TQuery Reply with quote

Here is some code that I use:

ProdQuery->Close();
ProdQuery->SQL->Clear();
ProdQuery->SQL->Add("SELECT * FROM Products");
ProdQuery->SQL->Add("WHERE Prod_code = :code");
ProdQuery->ParamByName("code")->AsString = sPcode;
if(!ProdQuery->Prepared)
ProdQuery->Prepare();
ProdQuery->Open();
--- do something with query ---
ProdQuery->Close();

I'm using the Advantage database set up as a local server. But I used
the same code when I was using the BDE & dBase tables. HTH.
Don
Back to top
Jayme Jeffman Filho
Guest





PostPosted: Tue Dec 20, 2005 7:13 pm    Post subject: Re: Cancel TQuery Reply with quote

Yes, your code is exactly as I usally do.
The problem is after calling the Open method, what happen if you call
immediately the Close one ? Will the Open operation be suspended ?
Or the Close method only will be performed when the Open finished ?
If so you are not able to interrupt an Open or Parse operation. While
the application is waiting for the database server you can not interrupt it.
Maybe using a thread .

HTH

Jayme.


"Don Locke" <dgnospamlocke (AT) comcast (DOT) net> escreveu na mensagem
news:43a84fca$1 (AT) newsgroups (DOT) borland.com...
Quote:
Here is some code that I use:

ProdQuery->Close();
ProdQuery->SQL->Clear();
ProdQuery->SQL->Add("SELECT * FROM Products");
ProdQuery->SQL->Add("WHERE Prod_code = :code");
ProdQuery->ParamByName("code")->AsString = sPcode;
if(!ProdQuery->Prepared)
ProdQuery->Prepare();
ProdQuery->Open();
--- do something with query ---
ProdQuery->Close();

I'm using the Advantage database set up as a local server. But I used the
same code when I was using the BDE & dBase tables. HTH.
Don



Back to top
Robert den Holder
Guest





PostPosted: Wed Dec 21, 2005 11:01 am    Post subject: Re: Cancel TQuery Reply with quote

As fas as I know, the Open() is a blocking function, so when you pass that
statement, the query is completed. I want to cancel the query during the
execution.
When I'm using ADO-queries, I can execute the query asynchronous. Then the
Open() isn't blocking anymore, but if I call Close() the query is still
executing in the background. If I wan't to change the SQL statement, I get
an error. Something like: "The query is still executing"

So, I don't have the solution yet, but I'm close :-)

Robert.
Quote:
ProdQuery->Open();
--- do something with query ---
ProdQuery->Close();

I'm using the Advantage database set up as a local server. But I used the
same code when I was using the BDE & dBase tables. HTH.
Don



Back to top
Don Locke
Guest





PostPosted: Wed Dec 21, 2005 12:43 pm    Post subject: Re: Cancel TQuery Reply with quote

You should do a Query->Close() & then a Query->Clear() before attempting
to change the SQL statement. The query should stop executing when the
close statement is issued.
Don
Back to top
Jayme Jeffman Filho
Guest





PostPosted: Thu Dec 22, 2005 11:28 am    Post subject: Re: Cancel TQuery Reply with quote

I'm very sorry. I've never worked with ADO components.

Jayme.


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (Desktop) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.