Results 1 to 9 of 9

Thread: Others than Doevent, How to load large data

  1. #1

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Others than Doevent, How to load large data

    Hi All,
    I would like to load large amount of data from database. Thus, I'm using Doevents to tie up system resources for a long period.However, by using Doevents would increase loading time of record.Hereon, beside that doevents what else of method have same feature with doevent or better solution of my condition.


    Thanks a lot
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  2. #2

  3. #3
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Others than Doevent, How to load large data

    Why are you loading large amount of data from database? Computations? Have you considered processing on the database using stored procedures to reduce traffic?

  4. #4

  5. #5

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: Others than Doevent, How to load large data

    Thanks Leinad and RhinoBull with extremely Fasy Reply..
    I post one of my code

    vb Code:
    1. Public Sub LoadAllMachine()
    2. Dim rsGetMachinePos As adodb.Recordset
    3. Dim rsGetStatus As adodb.Recordset
    4. Dim strStream As adodb.Stream
    5. Dim PictureShow As String
    6. Dim i As Integer
    7. Dim vbalvalue As Double, TotalProgress As Double
    8. i = 1
    9.     clearAllMachine
    10.     Set rsGetMachinePos = SQLSELECT("ObjLeft,ObjTop,ObjWidth,ObjLength,Mac_Code,Status,Condition,MachineImage", "Machine_Desc", " WHERE Loc = '" & frmLoadMachineLoc.lvwShowBlock.SelectedItem.Text & "' AND ObjLeft > 0", "", "", "Maintenance")
    11.         Do While Not rsGetMachinePos.EOF
    12.                 'DoEvents
    13.                 With frmProgressbar
    14.                     .Show
    15.                     .ZOrder (0)
    16.                     .FormName = frmLoadMapofMachine
    17.                     If i = rsGetMachinePos.RecordCount Then
    18.                          vbalvalue = 100
    19.                         .vbalProgressBar1.Value = vbalvalue
    20.                         .vbalProgressBar1.Text = vbalvalue
    21.                     Else
    22.                         vbalvalue = 100 / rsGetMachinePos.RecordCount
    23.                         TotalProgress = TotalProgress + vbalvalue
    24.                         .vbalProgressBar1.Value = Fix(TotalProgress)
    25.                         .vbalProgressBar1.Text = Fix(TotalProgress) & " %"
    26.                     End If
    27.                    
    28.                     .lblProgressbar.Caption = "    Loading Data : " & rsGetMachinePos.Fields(4) & Space(10) & i & " of " & rsGetMachinePos.RecordCount
    29.                 End With
    30.                 Me.Enabled = False
    31.                 mdiForm2.Enabled = False
    32.             Me.Enabled = False
    33.             mdiForm2.Enabled = False
    34.             With lblMachine(i)
    35.                
    36.                 Load lblMachine(i)
    37.                 .Move rsGetMachinePos.Fields(0), rsGetMachinePos.Fields(1), rsGetMachinePos.Fields(2), rsGetMachinePos.Fields(3)
    38.                 .AutoRedraw = True
    39.                 .Visible = True
    40.                 .Appearance = 0
    41.                 .BorderStyle = 1
    42.                 .ZOrder (1)
    43.                 .MouseIcon = ImageList1.ListImages.Item(1).Picture
    44.                 .MousePointer = 99
    45.                
    46.             PictureShow = IIf(IsNull(rsGetMachinePos.Fields(7)), "", rsGetMachinePos.Fields(7))
    47.               If Not PictureShow = "" Then
    48.                     Set strStream = New adodb.Stream
    49.                     strStream.Type = adTypeBinary
    50.                     strStream.Open
    51.                     strStream.Write rsGetMachinePos.Fields(7).Value
    52.                     strStream.SaveToFile "C:\Temp.bmp", adSaveCreateOverWrite
    53.                    .Picture = LoadPicture("C:\Temp.bmp")
    54.                    .PaintPicture .Picture, 0, 0, .ScaleWidth, .ScaleHeight
    55.                    .Tag = rsGetMachinePos.Fields(4)
    56.                     Kill "C:\Temp.bmp"
    57.                End If
    58.                
    59.                     Set rsGetStatus = SQLSELECT("Status", "WoList", " WHERE Status <> 'Completed' AND Mac_code = '" & rsGetMachinePos.Fields(4) & "'", "", "", "Maintenance")
    60.                     If Not rsGetStatus.EOF Then
    61.                         SetupBackground i, rsGetMachinePos.Fields(6), rsGetStatus.Fields(0), rsGetMachinePos.Fields(5), rsGetMachinePos.Fields(0) - 50, rsGetMachinePos.Fields(1) - 50, rsGetMachinePos.Fields(2) + 100, rsGetMachinePos.Fields(3) + 100
    62.                         .Tag = rsGetStatus.Fields(0) & "," & rsGetMachinePos(4)
    63.                     Else
    64.                         SetupBackground i, rsGetMachinePos.Fields(6), "", rsGetMachinePos.Fields(5), rsGetMachinePos.Fields(0) - 50, rsGetMachinePos.Fields(1) - 50, rsGetMachinePos.Fields(2) + 100, rsGetMachinePos.Fields(3) + 100
    65.                         .Tag = "OK" & "," & rsGetMachinePos(4)
    66.                     End If
    67.                
    68.             End With
    69.             i = i + 1
    70.             rsGetMachinePos.MoveNext
    71.         Loop
    72.         rsGetMachinePos.Close
    73.         Unload frmProgressbar
    74.  
    75. End Sub

    SP is one of the choice suggested from leinad, but i need to take long time for recode my whole system. I had promised my superior to test run the system on 1st day of the next year. I think would change whole code and reducing loading time by SP in next version.
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  6. #6
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Others than Doevent, How to load large data

    The query is not the only bottleneck, its setting up the picturebox array. Consider loading by demand, show only a subset of the data at any given time and load only their pictures instead of everything... the other data show as text until picture required (picture bytes queried separately). That way you also minimize the recordsets you need to return.
    Last edited by leinad31; Dec 25th, 2007 at 11:48 PM.

  7. #7

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: Others than Doevent, How to load large data

    Thanks advice from leinad31. That was one of the part of my query.
    The main problem is if I'm using Doevents to hold the resources it would create longer time to display record. If I do not use the Doevents as the code of my previous post, It would not show the data like
    vb Code:
    1. .lblProgressbar.Caption = "    Loading Data : " & rsGetMachinePos.Fields(4) & Space(10) & i & " of " & rsGetMachinePos.RecordCount
    at run time.

    I want my label to show which record is retrieving.

    Thanks leinad :-)
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  8. #8
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Others than Doevent, How to load large data

    DoEvents is there to allow other activities such as repaints. If you don;t want to run DoEvents every iteration then use a counter and Mod; If (counter Mod 100) = 0 Then DoEvents. Other than that, you'll have to redesign the process cause right now your really just prioritizing the progress bar rather than optimizing the picture download process.

  9. #9

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: Others than Doevent, How to load large data

    Thanks Leinad31 , Can you providing some tips for me or example how could optimizing the picture download process.
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width