Jump to content

[SOLVED] - Strange delay in loading .ado objects


Recommended Posts

Hi all,

I call a .xml file in this way:

If FileExists($myxmlfile) Then
                If $call_ado = 0 Then
                    _ADOCalls($myxmlfile)
                    $call_ado = 1
                EndIf
                _PopulateListView()
             GUISetState(@SW_SHOW, $DB_GUI)
         Else
            EndIf

Func _ADOCalls($file_xml)
    With $adoRsItems
        .CursorLocation = 3; adUseClient
        .CursorType = 2; adOpenDynamic
        .LockType = 3; adLockPessimistic
        If FileExists($file_xml) Then .Open($file_xml)
    EndWith
EndFunc   ;==>_ADOCalls

Func _PopulateListView()
    _GUICtrlListView_DeleteAllItems($hListView)
    If $adoRsItems.EOF() Then
        $adoRsItems.Filter = 0
    EndIf
    $adoRsItems.MoveFirst()
    $J = $adoRsItems.Fields.Count() - 1
    While Not $adoRsItems.EOF()
     $Txt = ''
        For $I = 0 To $J
            $Txt &= $adoRsItems.Fields($I).Value & "|"
        Next
        If $sets[UBound($sets) - 1] <> $adoRsItems.fields(1).value Then _ArrayAdd($sets, $adoRsItems.fields(1).value)
        GUICtrlCreateListViewItem(StringTrimRight($Txt, 1), $ListView)
     $adoRsItems.MoveNext()
    WEnd
    GUICtrlSetData($LVNumber, _GUICtrlListView_GetItemCount($hListView))
EndFunc   ;==>_PopulateListView

I load 14,000 records.

If I use _arraysort($mydb) before writing data to .xml, the loading time becomes horrible (around 40 secs vs 8 secs)

(I need it sorted since I use _arraybinarysearch() to look for datas there and eventually change them.)

_ArrayConcatenate($dest, $new_added, 1)
                _ArraySort($dest)  ; <----------------------  Not needed here but I add since in previous lines it has been called
                _ArrayAdd($dest, "</rs:data>")
                _ArrayAdd($dest, "</xml>")
                _FileWriteFromArray($myxmlfile, $dest, 1)
            EndIf
                While FileOpen($myxmlfile) < 0
                    Sleep(1)
                WEnd
            _appendtemplate("headers")

How to solve it?

M.

Edited by marko001
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...