Accessing Data From a Thread.

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
bubs75
Posts: 4
Joined: Mon 08 Jun 2009 16:16

Accessing Data From a Thread.

Post by bubs75 » Mon 08 Jun 2009 16:38

I have created a query, and a thread.
On the threads creation it is passed the query to execute.

using the query I can obtain the total number of records retrieved so far using Data.RecordCount

Self.RecordCount returns 0 on account the of query not being Active. It seems the Active property isn't set until the query has finished executing.

What I would like to do is to be able to access the data without having to wait for the query to finish.

I can see the that the data contains records. I can also see if I call CreateFieldDefs manually it succesfully creates the field defintions.

I can even call CreateFields and I get a list of fields

Unfortunately Query.Fields[x].Value is null until execution has finished.

Is it possible to obtain data as it is retrieved and how do I go about it?

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 09 Jun 2009 09:09

To solve the problem you can set the TMSQuery.FetchAll property to False.
You can find more detailed information about this property in the SDAC help.

bubs75
Posts: 4
Joined: Mon 08 Jun 2009 16:16

Post by bubs75 » Tue 09 Jun 2009 11:02

Thanks!

It's a good thing this area of the program isn't using transaction handling.

FetchAll solved...ish, the problem

By setting FetchAll to false and FetchRows = 1 before the query opened and then setting FetchAll to True immediatly after the query opened the field data was initialised properly allowing the thread to pull in all the data in the background.

At the same time the program was able to process the incoming data.

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 10 Jun 2009 13:04

It is good to see that this problem has been solved.

Post Reply