Page 1 of 1

How to use TBackgroundWorker when querying a Database w/ SQL

PostPosted: September 27th, 2011, 2:58 pm
by normanlacap
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 .

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

PostPosted: September 28th, 2011, 7:26 am
by Kambiz
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.

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

PostPosted: September 29th, 2011, 3:00 pm
by normanlacap
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...

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

PostPosted: October 2nd, 2011, 11:27 am
by Kambiz
Could you please tell me which database you use and what the records are?

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

PostPosted: October 2nd, 2011, 12:47 pm
by normanlacap
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.

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

PostPosted: March 19th, 2014, 12:36 pm
by uparlayan
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?