How to use TBackgroundWorker when querying a Database w/ SQL

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

How to use TBackgroundWorker when querying a Database w/ SQL

Postby normanlacap » September 27th, 2011, 2:58 pm

Hi,
How do I use TBackgroundWorker when querying a Database using an SQL statement when the queries takes too long to complete. I've seen a sample program but it opens the table on a per record where the TBackgoundWorker is used to track the progress of the While not end of File. But how do I use it when I only issue an SQL statement?


Any idea how to do it? Thanks .
normanlacap
Member
Member
 
Posts: 3
Joined: September 27th, 2011, 2:33 pm

Re: How to use TBackgroundWorker when querying a Database w/

Postby Kambiz » September 28th, 2011, 7:26 am

Hi,

It depends on type of your query.
If your query has no return value (like DELETE, INSERT, ...), you can simply execute the query in OnWork event of the BackgroundWorker.
If the query is a SELECT query, you can calculate the final result within the OnWork event or send the fetched record to the main thread.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: How to use TBackgroundWorker when querying a Database w/

Postby normanlacap » September 29th, 2011, 3:00 pm

Thank you very much sir... if it isn't too much to ask sir, can you provide me a demo or a snippet so i would have an idea on how to use it...by the way... I'm using a Select query that returns a value... I've unsuccessfully used it just as i saw in one of your demo...in the execute where my query runs but i'm unable to cancel it...it runs tru the end of the query.. i would like also to show some progress of how many records were being processed... thank you very much in advance... your components are very much helpful and if i develop enough competency i also would like to contribute too...
normanlacap
Member
Member
 
Posts: 3
Joined: September 27th, 2011, 2:33 pm

Re: How to use TBackgroundWorker when querying a Database w/

Postby Kambiz » October 2nd, 2011, 11:27 am

Could you please tell me which database you use and what the records are?
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: How to use TBackgroundWorker when querying a Database w/

Postby normanlacap » October 2nd, 2011, 12:47 pm

I'm using AbsoluteDB to query a person's Name.
TGenInfo table with the following fields:
LName,
FName,
MName,
Qualifier,
Gender ("Male","Female"),
RankId ("PO1',"PO2","PO3","SPO1"...,"SPO4","INSP","SINSP","CINSP","SUPT","SSUPT","CSUPT","PDIR"),
Unit,
Age,
Age_Range ("21-24","25-30","31-35","36-40","40-55")

Each of these fields are what I can based my Search on.
If you have a different Database such as MySQL or Firebird that will be fine.

Thank you sir for replying to my query.
normanlacap
Member
Member
 
Posts: 3
Joined: September 27th, 2011, 2:33 pm

Re: How to use TBackgroundWorker when querying a Database w/

Postby uparlayan » March 19th, 2014, 12:36 pm

Hi,

Subjects were to continue. I once was forgotten. I revive subject behalf, the same question can I ask for ADO, SQL Server and SELECT querys?
uparlayan
Member
Member
 
Posts: 1
Joined: March 19th, 2014, 12:32 pm


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 23 guests

cron