Re: Deadly slow code ... where am I screwing up

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Val Mazur (group51a_at_hotmail.com)
Date: 06/02/04


Date: Wed, 2 Jun 2004 18:34:36 -0400

Hi Dale,

It is probably slow when you open recordset. Right?
Two suggestions. First open your recordset as read-only, forward-only. It
would improve performance significantly. Since you do not need to edit
anything in a recordset, it will be the best option. Second, check if you
have an index in a database for the upc field. If not, then process will be
slow, because database engine will spend most of the time to sort the data.
If you create index, then it should be pretty fast unless you select huge
amount of records and it would take some time to transfer data over network.

-- 
Val Mazur
Microsoft MVP
"Dale" <dale0610@hotmail.com> wrote in message 
news:%23ZvRedMSEHA.2000@TK2MSFTNGP11.phx.gbl...
> Hi all, I'm trying to load two fields from a table into a listview - I 
> have the following code in the form's load event and it's deadly slow 
> popping up.  What's the best way to populate a listview with table 
> columns?  Thanks.
>
>
>     Dim itmx As ListItem
>     Dim sSelect As String
>
>     lvProducts.ListItems.Clear
>
>     Set rsProducts = New ADODB.Recordset
>
>     rsProducts.Open "SELECT upc, description FROM PRODUCTS ORDER BY upc", 
> cnn, adOpenStatic, adLockPessimistic
>
>
>     rsProducts.MoveFirst
>
>     While rsProducts.EOF = False
>         Set itmx = lvProducts.ListItems.Add(, , 
> rsProducts.Fields.Item("upc").Value)
>         itmx.SubItems(1) = rsProducts.Fields.Item("description").Value
>
>         rsProducts.MoveNext
>     Wend
>
>     rsProducts.Close
>
>     lvProducts.View = lvwReport 


Relevant Pages

  • Re: dbseechanges error 3622
    ... "Alex Dybenko" wrote: ... the rule is - when you open recordset for updating - then you need to use ... else you can open it as snapshot, then dbseechanges is not required ... Dim db As Database, rs As Recordset, rs1 As Recordset ...
    (microsoft.public.access.modulesdaovba)
  • Re: dbseechanges error 3622
    ... the rule is - when you open recordset for updating - then you need to use dbseechanges like this: ... Dim db As Database, rs As Recordset, rs1 As Recordset ... Set rs1 = db.OpenRecordset ...
    (microsoft.public.access.modulesdaovba)
  • Re: Working with Sheridan Grid
    ... You can open recordset from the SP, ... "Vlad" wrote in message ... > "Val Mazur" wrote in message ...
    (microsoft.public.sqlserver.tools)
  • Re: Working with Sheridan Grid
    ... You can open recordset from the SP, ... "Vlad" wrote in message ... > "Val Mazur" wrote in message ...
    (microsoft.public.sqlserver.programming)
  • Re: Working with Sheridan Grid
    ... You can open recordset from the SP, ... "Vlad" wrote in message ... > "Val Mazur" wrote in message ...
    (microsoft.public.vb.database)