Solved

Rs.CursorLocation

Posted on 2002-03-18
6
901 Views
Last Modified: 2007-11-27
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

0
Comment
Question by:mosheshitrit
  • 3
  • 2
6 Comments
 
LVL 18

Expert Comment

by:mdougan
ID: 6877796
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....
0
 
LVL 20

Expert Comment

by:hes
ID: 6877804
Before you check the recordcount do a Movelast then the recordcount will be populated
0
 

Author Comment

by:mosheshitrit
ID: 6879450
To Hes:

10x but the movelast action does not help
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:mosheshitrit
ID: 6879455
to mdougan:

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

0
 
LVL 18

Accepted Solution

by:
mdougan earned 200 total points
ID: 6879872
What type of cursor are you using?  If you are using a foreward only cursor, then you will probably not have valid counts.  You could try opening an adKeyset or one of the dynamic cursor options and that should help.

I'd be surprised about the AbsolutePosition showing -1, are you sure that you were positioned on the first record?  Or on the last record?  Absolute position should tell you the absolute record number of the record that you are positioned on.  So, if you're on the last record then the AbsolutePosition should be equal to the RecordCount.
0
 

Author Comment

by:mosheshitrit
ID: 6880250
To  mdougan:

Thanks for the quick solution.

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

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now