Populating a combo from a database table faster
- From: <tglunz@xxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 29 Mar 2006 14:34:05 -0600
Good afternoon,
I was wondering if anyone know a faster way to populate a combo? In some
cases these combos maybe populated from a query which may return 20,000
records. I am not a fan of populating a combo with that many records, but
it is not my choice. The following code take 7 second to populate the combo
with 20,000 values:
Combo.items.clear;
CodeQuery.First; // ADO dataset
while CodeQuery.Eof = False do
begin
Combo.Items.Add(CodeQuery.Fields[0].AsString);
CodeQuery.Next;
end;
This compares to a DBGrid which takes 2 seconds for several fields (all the
data is fetched), so something tells me there must be a quicker way. I
cannot use a DBLookupCombo. This code is part of a procedure which could be
called several times from an unknown number of fields. I was hoping the
dataset might have a way to send all the fetched data for one field to a
TStringList and then set Combo.Item to that list. Even if I eliminate the
line "Combo.Items.Add(CodeQuery.Fields[0].AsString);" from the above code,
the process still takes 6 seconds, so most of the time is wasted scrolling
through the database table. Anyone have some ideas on how to speed this up?
I even tried loading the data to a dblookupcombo with the lookupdatasource
and lookupdatafield set and then trying to access the items in the combo,
but items (stringlist) does not exist for that object. Any help would be
appreciated.
Thanks in advance,
Tom Glunz
tglunz@xxxxxxxxxxxxxxxxxxxxx (remove the nospam.)
.
- Follow-Ups:
- Re: Populating a combo from a database table faster
- From: Chris
- Re: Populating a combo from a database table faster
- From: Adem
- Re: Populating a combo from a database table faster
- From: Kevin Frevert
- Re: Populating a combo from a database table faster
- Prev by Date: Re: installing ncoci8 in BDS2006
- Next by Date: Re: Populating a combo from a database table faster
- Previous by thread: Master/detail change problem
- Next by thread: Re: Populating a combo from a database table faster
- Index(es):