I have an app that load 75000 records into a grid.
<Dont ask me why>

The Grid is bound to a Data Control.

When i try making the same form in vb6.  using ADO data control.. its all good.. but the form takes like 8 seconds to load up..  
understandably.. as there are alot of records.

but in the VB3 App.. the form just pops up like that are 100 records. really fast.

The SQL statements are the same.  "Select * from MyTable "

I will note that in the VB3 app.. as i scrolled down the list.. there were pauses.. as if it was fetching the data..
Kind of like SQL Server Enterprise manager does.. or access..

Anyone know why this behavior is happening?
Who is Participating?
Valliappan ANConnect With a Mentor Senior Tech ConsultantCommented:
Try like this: you'd get it faster.

Set rs = New Recordset
rs.Open "Select * From MyTable",Conn1,adOpenKeySet,adLockOptimistic, adAsyncFetch

'now you can do operations. it will still retrieve records by the time, but appears faster.

'if you need to do something till it retrieves everything do:

Do while rs.StillExecuting
    your code, like DoEvents.

Thats it. You could also restrict the no. of records retrieved, by using the top command, so that your system won't crash.

Select top 10000 * From myTable

hope this helps you.
You could set the .cachesize property of the data control in order to restrict the number of records locally loaded in memory.
Valliappan ANSenior Tech ConsultantCommented:
You might link your grid to recordset, by setting the datasource property, of the grid to recordset.

Or, I am not sure, the datacontrol, has such a property, for Async Retrieval.

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

TheAnswerManAuthor Commented:
I am not asking about how to optimize my query.

The current VB3 app connects with the same SQL and appears to be 10 times faster.

I say appears.. becasue as I scroll through the VB app.. it appears to fetch the data.. kind of like opening a table in SQL Server Enterprise manager.

Ie: it opens right up.. but to see the last records.. you
have to pull the scrollbar all the way down a few times.

the VB6 App.. appears to fetch all the records.. and THEN put them into the grid.

The VB3 app.. appears to getch a few records... and when i scroll down the list.. the grid is initiall blank.. and then fills up with the data.. as if if fetched it from the server.

There is no code to do this fetching.. just a bound grid.
Valliappan ANSenior Tech ConsultantCommented:
We had a similar problem using recordset as datasource for datagrid in VB6, when number of records is more.

So, we used the AsyncFetch option, which is meant to do some fetch (I hope, as per InitialFetchSize), and then allowing for other activities, when it retrieves further, if I am right.This is the part, we changed.(Note the last parameter, which does what you are telling about, in VB3.0, if I am right.)

Set rs = New Recordset
rs.Open "Select * From MyTable",Conn1,adOpenKeySet,adLockOptimistic, adAsyncFetch

For its correct usage, check this link:

The reason of speed difference could be, as I hope, that VB3 used DAO and in VB6, you use ADO, which is still a new technology, while DAO had undergone several changes in VB versions.

Hope this helps.
TheAnswerManAuthor Commented:
appreciate the help everyone.. but was asking about why VB3 Code was appearing to fetch the data instantly.. but not really, as when you scrolled.. it appeared to "fetch" the data.

I used the same exact code for the vb6 project.. except ADO control instead.

Hi TheAnswerMan,
You've requested to delete this question, but its status has remained as 'Pending Delete' because one or more comments have been added.  Normally, the only way to fully delete such a Question is to post a message to Community Support and ask for assistance.

EE is making a one-time database sweep to purge the Pending Delete Questions automatically.  During this sweep:

    TheAnswerMan -- To allow the deletion to proceed:  Do nothing.
    EXPERTS -- Please DON'T POST a comment except to contest this deletion.

In the future, please refer to http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp#8 for instruction on deleting questions.

DanRollins -- EE database cleanup volunteer
Valliappan ANSenior Tech ConsultantCommented:
As mentioned earlier, DAO (which you used in VB3) looks to be more faster than ADO, in case of Access, which is testified by many experts here.

Listening further for TheAnswerMan response.
Moondancer - EE Moderator
Moderator, my recommended disposition is:

    Accept valli_an's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
Comment from expert accepted as answer

E-E Moderator
All Courses

From novice to tech pro — start learning today.