I would like to know how to increase the speed of data loading into flexgrid from Database(SQL Server).currently im using a loop but this takes a lot of time when there are alot of data...pls give me a solution to this problem..

Thank you

6 Years
Discussion Span
Last Post by PoisonedHeart

Ancie, please show us the loop code you are using to load the grid. Your problem might lie there.


If the form is shown, you might be able to use LockWindowUpdate API in the following manner

LockWindowUpdate Grid.hWnd
'do loading here
LockWindowUpdate 0

Another method would be to hide the grid that you are loading and show a dummy grid along with a progress bar...

Good Luck


You might as well try to make the control invisible first, then when all the data has been loaded, set the control's visibility to true, for some controls, it increases the speed...

and just to add up if the loop makes your app hang...then try to insert a DoEvents keyword before the loop statement ending keyord...

For i = 0 to rs.RecordCount -1

'Your code here....to populate the flexgrid

Next i

or with the While loop statements, just add the DoEvents keyword before the Loop keyword

Do NOT While rs.EOF

'Your code here....to populate the flexgrid


NOTE: please take note of your usage of the DoEvents keyword, especially when you are performing long executing codes, it might perform undesireable effects...just like this one:

Private Sub Form_Load()
'While the loop executes, try to close the form, and notice that the loop still being executed even if the form has been unloaded...
For i = 0 To 10000
    Me.Caption = i
Next i
End Sub

Anyway, the decision is all yours, of what technique you would use...Happy Coding!

Edited by PoisonedHeart: wrong spelling and grammars...

This article has been dead for over six months. Start a new discussion instead.
Be sure to adhere to our posting rules.