copy recordset records to combobox 
Author Message
 copy recordset records to combobox

Hi

what is the fastest way to copy the records of a recordset into a combobox.

  While Not objRecTables.EOF
     cb1.AddItem (objRecTables.Fields(1).Value)
     objRecTables.MoveNext
  Wend

THIS IS TOOO SLOW

Thanks
Timo



Sun, 16 Jan 2005 19:02:25 GMT  
 copy recordset records to combobox

Quote:
> Hi

> what is the fastest way to copy the records of a recordset into a
combobox.

>   While Not objRecTables.EOF
>      cb1.AddItem (objRecTables.Fields(1).Value)
>      objRecTables.MoveNext
>   Wend

> THIS IS TOOO SLOW

How many records are you trying to insert there?

I'm in the middle of trying different things to find out what kind of
performance gain I can get from moving onto eVC in stead of eVB. Some of my
findings during this process were:

1) My test case is that I do 23 various selects on 23 different Comboboxes.
The reason for this split is mainly that the user should be able to pick one
of the 23 types in one combobox, and the combobox_change event is then used
to show the correct of the other 23 comboboxes. I fill these comboboxes with
a total of 663 lines.

2) When filling the comboboxes using a tight loop like yours put the filling
time to around 18 seconds.

3) As this time is too much when I want to show my data, I decided to put
the fill onto a timer, where I either select one set of data, or insert one
record into the combobox(es) on each clock tick. The tick were set to 1
millisecond. If I hand't put the fill on a timer, the program would still be
unresponsive, even when the data filling took place on another form.
This filling took "only" 14 seconds. I still fail to find out how this time
can be shorter than the tight loop filling.

4) Trying to do a fill of 1000 lines into a combobox (fixed lines), I
created a small simple for - next loop and timed this. It took 6 seconds to
fill the combobox.

5) Trying to do everything but the fill in my timer system cut the time back
to 8 seconds. (still trying to insert 663 lines from 23 selects.)

6) Skipping everything but the selects themselves, I got down to 2 seconds.

7) Testing fill rate for a combobox in C gave me 12 seconds to fill in 10000
(ten thousand) fixed text lines.

This reveals the following (IMO):

C programs are (for this task) 5 times faster than VB programs. A difference
were expected as C is compiled and VB is interpreted.
Most of my time is used in the insertion of the data into the comboboxes.
The least time is spent on data selection.
BTW: For many, short selects like this, SQL Server for CE very unexpectedly
proves to be slower than cedb data.

And where does this bring us?

Well, if nobody can come up with a faster way to insert data into comboboxes
(and treeviews), it seems like a good idea to give C somewhat more than a
cursory look.

Keld Laursen



Sun, 16 Jan 2005 19:47:27 GMT  
 copy recordset records to combobox
If the records are not sorted, and the combobox is sorted, this could be the
cause of the slow processing. Turn sorted off before the insert, then turn
it back on at the end.


Quote:
> Hi

> what is the fastest way to copy the records of a recordset into a
combobox.

>   While Not objRecTables.EOF
>      cb1.AddItem (objRecTables.Fields(1).Value)
>      objRecTables.MoveNext
>   Wend

> THIS IS TOOO SLOW

> Thanks
> Timo



Mon, 17 Jan 2005 09:23:37 GMT  
 copy recordset records to combobox

Quote:
> If the records are not sorted, and the combobox is sorted, this could be
the
> cause of the slow processing. Turn sorted off before the insert, then turn
> it back on at the end.

Sorry, but that won't work!

The combobox sorting is read only during run-time, so you cannot turn it on
and off.

Some tests I made with sorted/unsorted data indicated that the overhead on
having to do sorting in the Combobox uncurred an overhead of no more than
20%. Still, that can be considered substantial.

Keld Laursen



Mon, 17 Jan 2005 14:18:24 GMT  
 copy recordset records to combobox
Sigh. Another tiny difference not in the differences list. Note that the
impact of sorted varies considerably with the code - if repaint occurs the
effect can be much greater.


Quote:


> > If the records are not sorted, and the combobox is sorted, this could be
> the
> > cause of the slow processing. Turn sorted off before the insert, then
turn
> > it back on at the end.

> Sorry, but that won't work!

> The combobox sorting is read only during run-time, so you cannot turn it
on
> and off.

> Some tests I made with sorted/unsorted data indicated that the overhead on
> having to do sorting in the Combobox uncurred an overhead of no more than
> 20%. Still, that can be considered substantial.

> Keld Laursen



Tue, 18 Jan 2005 06:55:12 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Appending a recordset with a copied? recordset record

2. Copy records from recordset to table

3. how to copy n records from a recordset?

4. how can i copy a current record from recordset in vbscript

5. Help: How to copy current record into a new recordset

6. Copy a record and then append it to the recordset

7. How do create a copy of a recordset to make a new record

8. Copy record from recordset to a new rec of same set

9. Module-level multiple-record recordset vs temp single-record recordset

10. Module-level multiple-record recordset vs temp single-record recordset

11. Adding records to a combobox if record is notinlist

12. Quickest Way to copy DB1.recordset to DB2.recordset

 

 
Powered by phpBB® Forum Software