Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Slow ListView

Status
Not open for further replies.

JBell

Programmer
Aug 9, 2001
7
0
0
US
I have a listview in VB6 that is loading about 5000 items and it is taking 10-15 seconds. I load it from a SQL stored Proc. When I exec the sp from query analizer it returns almost instantly. Any thought on speed ?

sortCMD = "EXEC LB_Inventory_V"

Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient

db.Open sADOConnect

Set RS = New Recordset

RS.Open sortCMD, db, adOpenStatic, adLockOptimistic

Dim mItem As Variant
Dim lx As Long
Dim strItem As String
Dim STRA As String
Dim STRB As String
Dim Refreshed As Boolean
With List
.ListItems.Clear
.Sorted = False
If RS.RecordCount > 0 Then RS.MoveFirst
Do Until RS.EOF
STRA = .ColumnHeaders(1)
strItem = RS!ITEMNMBR
'Add the item
Set mItem = .ListItems.Add(, , strItem)

'Do the subitems

mItem.SubItems(1) = RS!ITEMDESC
mItem.SubItems(2) = RS!VENDORID
mItem.SubItems(3) = RS!VNDITNUM
mItem.SubItems(4) = RS!USCATVLS_1
mItem.SubItems(5) = RS!USCATVLS_6
mItem.SubItems(6) = RS!LISTPRICE
mItem.SubItems(7) = RS!LOCNCODE
mItem.SubItems(8) = RS!QTYONHND


RS.MoveNext '
lx = lx + 1
Loop
RS.MoveFirst
List.ListItems(1).EnsureVisible
.Refresh
End With
AddToList = True


Thanks,

 
Try this if would help you:

Dim i As Integer
.ListItem.Clear
RS.movefirst

Do While Not RS.EOF
'Get ITEMNMBR
For i = 0 to RS.Field.Count-1
Set mItem = .ListItem.Add (,,Trim$(RS.Field(i).Name)
mItem.SubItems(1) = RS!ITEMDESC
mItem.SubItems(2) = RS!VENDORID
mItem.SubItems(3) = RS!VNDITNUM
mItem.SubItems(4) = RS!USCATVLS_1
mItem.SubItems(5) = RS!USCATVLS_6
mItem.SubItems(6) = RS!LISTPRICE
mItem.SubItems(7) = RS!LOCNCODE
mItem.SubItems(8) = RS!QTYONHND
next i
RS.movenext
Loop
Set mItem = Nothing

If this wont speed up loading item in Listview
then it has to do with getting recordset from SQL try - Set Recordset = yourDBConnection.Execute(SQL)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top