Board index » delphi » TADODataset fetches all rows on .Open?

TADODataset fetches all rows on .Open?


2003-07-07 09:51:49 PM
delphi281
Hi,
I've trying to get some ADO stuff working - I have a table
with 1.000.000 rows. Now, if I'd do a SELECT *
FROM <table>- and do a .Open on TADODataset, it
seems to fetch ALL rows. It takes quite some time. And
yes, I know - I shouldn't present 1.000.000 rows to a
user, but that is not the question :-)
Questions:
1) DOES it fetch all rows?
2) If Yes, how can I avoid that?
(cachesize is 1)
--
With regards,
Martijn Tonies
Database Workbench - the developer tool for InterBase & Firebird
Upscene Productions
www.upscene.com
 
 

Re:TADODataset fetches all rows on .Open?

Quote
>Questions:
>
>1) DOES it fetch all rows?
Yes
That strikes me as _really stupid_... Is this a driver thingy?
Quote
>2) If Yes, how can I avoid that?
You can set the MaxRecords property to limit the number of records returned
but
there is no build in way to fetch records that come after that.
That's what I read... :-/
Quote
Your best approach is to require the user to enter some selection criteria.
Set
MaxRecords at the maximum number of records you want fetched.
If the query with user selection returns RecordCount=MaxRecords then warn the
user that they need to narrow their selection criteria.
As said - not an option. I will make the max-rows thing user configurable then.
--
With regards,
Martijn Tonies
Database Workbench - the developer tool for InterBase & Firebird
Upscene Productions
www.upscene.com
 

Re:TADODataset fetches all rows on .Open?

"Martijn Tonies" <m.tonies@upscene!nospam!.com>writes
Quote

>>Questions:
>>
>>1) DOES it fetch all rows?
>Yes

That strikes me as _really stupid_... Is this a driver thingy?
Nope, welcome to client/server development.
krf
 

Re:TADODataset fetches all rows on .Open?

Kevin,
Quote
>>>Questions:
>>>
>>>1) DOES it fetch all rows?
>>Yes
>
>That strikes me as _really stupid_... Is this a driver thingy?

Nope, welcome to client/server development.
Since when?
What other database engine fetches all rows automatically
when you don't ask for it?
--
With regards,
Martijn Tonies
Database Workbench - the developer tool for InterBase & Firebird
Upscene Productions
www.upscene.com
 

Re:TADODataset fetches all rows on .Open?

Quote
>>Questions:
>>
>>1) DOES it fetch all rows?
>Yes

That strikes me as _really stupid_... Is this a driver thingy?
Its the way ADO is designed to work
 

Re:TADODataset fetches all rows on .Open?

What about eoAsyncExecutem & eoAsyncFetch?
Wouldn't these options on an ADOQuery coupled with an OnFetchProgress event
handler updating some progress indicator be a helpful way of getting a large
number of records without the user having to wait for all of them to arrive?
I ask this because I have a similar situation where a significant number of
records must be retrieved but would like to keep the user on the loop as to
what's going on the backend and even show him the records that have been
retrieved.
I built a small project that I am using to test this options out; the problem
I'm having is that the grid is not updated and I get an Access Violation
when the fetch process starts; after that the process continues, I get some
(weird) updates on a progress bar and eventually the fetch completes.
When the fetch completes the grid displays a single record, but it allows
"paging" within that single record (i.e. the rest of the records are
displayed in the same grid row whenever one tries to navigate the grid);
even the navigator bar works in that same single grid row.
The event handler that does the updating is this one:
procedure TForm1.ADOQuery1FetchProgress(DataSet: TCustomADODataSet;
Progress, MaxProgress: Integer; var EventStatus: TEventStatus);
begin
if cancelFetch then begin
ADOConnection1.Close;
ShowMessage('Fetch cancelled')
end
else begin
ProgressBar1.Max:= MaxProgress;
ProgressBar1.Position:= Progress;
end;
Application.ProcessMessages;
ProgressBar1.Refresh
end;
I've seen a similar behavior done in the Great Plains Small Business Manager
program.
Does anyone (TeamB?) know how this should be properly done?
Best regards,
Mario Estrella
"Brian Bushay TeamB" <XXXX@XXXXX.COM>writes
Quote

>>>Questions:
>>>
>>>1) DOES it fetch all rows?
>>Yes
>
>That strikes me as _really stupid_... Is this a driver thingy?

Its the way ADO is designed to work
--
Brian Bushay (TeamB)
XXXX@XXXXX.COM