Link to home
Start Free TrialLog in
Avatar of mosheshitrit
mosheshitrit

asked on

Rs.CursorLocation

Hi everyone,

When i use CursorLocation adUseClient on opening of a table with large ammount of records, the opening is very very slow.
on the other hand, when i use CursorLocation adUseServer,
i get -1 value on the RecordCount and AbsolutePosition properties.

How can i know the RecordCount and AbsolutePosition properties on CursorLocation adUseServer ?

10x

Avatar of mdougan
mdougan
Flag of United States of America image

Well, you need to understand the difference behind these cursorlocations.  When you specify adUseClient, it creates a "client-side" cursor, meaning that it retrieves all of the data for the recordset and transfers it back to your program to manage.  That is why it takes so long.

A "server-side" cursor simply has to open up and return you one buffer's worth of data.  However, since not all rows have been returned to the cursor, it doesn't yet know how many records there are.  So, the only way you can get an accurate record count is to read to the end of the cursor, and then, perhaps, the recordcount will reflect the number of records, or, you can look a the RS.AbsolutePosition property.

However, in reading to the end of the "server-side" cursor, you've just lost your performance advantage.

If you absolutely need the count at the beginning of returning records, but you absolutely want to use a server-side cursor, then you might consider issuing the same SQL Statement except instead of selecting columns, do a Select Count(*) from ..... get the count first, and then issue the normal select statement....
Avatar of hes
Before you check the recordcount do a Movelast then the recordcount will be populated
Avatar of mosheshitrit
mosheshitrit

ASKER

To Hes:

10x but the movelast action does not help
to mdougan:

Thanks for the explanation.
I can't use the RS.AbsolutePosition property because it returns -1 value

ASKER CERTIFIED SOLUTION
Avatar of mdougan
mdougan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To  mdougan:

Thanks for the quick solution.

Use CursorLocation adUseServer with cursorType
adKeyset and you will see both the RecordCount and AbsolutePosition properties.