adodb.recordset recordcount return -1

Posted on 2009-04-16
Last Modified: 2013-12-25
my record set did not return recount value always return -1

here is some code
set rs = new adodb.recordset

set rs = objhcon.execute (sSQL)

msgbox rs.recordcount

Open in new window

Question by:Luhana
    LVL 53

    Accepted Solution

    Why does RecordCount return as -1?
    (Recordcount is not supported with the default forward-only cursor. If you open a recordset in the following manner, you will have access to recordcount:)
    LVL 48

    Expert Comment

    by:Ryan Chong
    you can also try like this:

    set rs = new adodb.recordset
    rs.CursorLocation = adUseClient sSQL, objhcon, 1, 1
    msgbox rs.recordcount


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

    779 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

    13 Experts available now in Live!

    Get 1:1 Help Now