ADODB.RecordSet, RecordCount always return -1

Discussion in 'ASP General' started by Serge Myrand, Jun 23, 2004.

  1. Serge Myrand

    Serge Myrand Guest

    Hi,

    I have an ADODB.RecordSet that RecordCount alway return -1 and this
    RecordSet is plenty of record!

    R.RecordSet = -1
    R.eof = False
    R.BOF = False

    Is the cursor is lost somewhere?

    How can I do to get the number of record in the result set?

    Thank you in advance
    serge
    Serge Myrand, Jun 23, 2004
    #1
    1. Advertising

  2. Serge Myrand

    Serge Myrand Guest

    Great, thank you


    "Bob Barrows [MVP]" wrote:

    > Serge Myrand wrote:
    > > Hi,
    > >
    > > I have an ADODB.RecordSet that RecordCount alway return -1 and this
    > > RecordSet is plenty of record!
    > >

    > Your answer will be found here:
    > http://www.aspfaq.com/show.asp?id=2193
    >
    > HTH,
    > Bob Barrows
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    Serge Myrand, Jun 23, 2004
    #2
    1. Advertising

  3. Serge Myrand

    Serge Myrand Guest

    I am sorry for posting in the wrong forum, it's bad when searching
    answers..

    Serge Myrand wrote:

    > Hi,
    >
    > I have an ADODB.RecordSet that RecordCount alway return -1 and this
    > RecordSet is plenty of record!
    >
    > R.RecordSet = -1
    > R.eof = False
    > R.BOF = False
    >
    > Is the cursor is lost somewhere?
    >
    > How can I do to get the number of record in the result set?
    >
    > Thank you in advance
    > serge
    Serge Myrand, Jun 23, 2004
    #3
  4. Serge Myrand wrote:
    > Hi,
    >
    > I have an ADODB.RecordSet that RecordCount alway return -1 and this
    > RecordSet is plenty of record!
    >

    Your answer will be found here:
    http://www.aspfaq.com/show.asp?id=2193

    HTH,
    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Jun 23, 2004
    #4
  5. Serge Myrand

    IPT Guest

    I went to the web, and still unable to get it work.

    My codes:

    sSQL = "SELECT * FROM myTable"
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open sSQL, myConn, 1, 3
    recCount = rs.recordcount
    rs.Close
    Set rs = Nothing
    response.write recCount

    It returns -1.

    Help!

    > Serge Myrand wrote:
    > > Hi,
    > >
    > > I have an ADODB.RecordSet that RecordCount alway return -1 and this
    > > RecordSet is plenty of record!
    > >

    > Your answer will be found here:
    > http://www.aspfaq.com/show.asp?id=2193
    >
    > HTH,
    > Bob Barrows
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >
    IPT, Jun 27, 2004
    #5
  6. Are you Serge?

    What is your backend database?

    IPT wrote:
    > I went to the web, and still unable to get it work.


    Why bother? If you read the article I linked to, you will find a more
    efficient method (using GetRows) for getting the record count than using an
    expensive cursor for your recordset.

    >
    > My codes:
    >
    > sSQL = "SELECT * FROM myTable"
    > Set rs = Server.CreateObject("ADODB.Recordset")
    > rs.Open sSQL, myConn, 1, 3


    You do not need an ultra-expensive keyset cursor (although it should work).
    All you need is a static cursor. The locktype does not matter.
    rs.Open sSQL, myConn, 3, 3, 1

    > recCount = rs.recordcount
    > rs.Close
    > Set rs = Nothing
    > response.write recCount
    >


    Does this reflect your actual purpose? You are opening a recordset for the
    sole purpose of getting the record count? That's crazy! Don't pull all the
    records from your table across the wire simply to count them.

    sSQL = "SELECT count(*) FROM myTable"
    set rs = conn.execute(sSQL,,1)
    recCount = rs(0)
    rs.Close
    Set rs = Nothing
    conn.Close
    Set conn= Nothing
    response.write recCount

    > It returns -1.
    >
    > Help!


    It should not return -1 with a keyset cursor, unless the provider you are
    using for your connection does not support bookmarks. That is why I asked
    what database you are using, and why I am now asking you to show us your
    connection string (with any password information censored of course).

    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Jun 27, 2004
    #6
  7. Serge Myrand

    IPT Guest

    I'm not Serge.

    I use mySQL 4.0, does it support bookmark (.AbsolutePage)?

    I used to use Ms Access, and has many functions. Since migrate to mySQL, I
    need to modify many codes pertaning to SQL systax. I can't use anymore saved
    queries, nested select, etc. Even the 'getdate()' has changed to 'Now()'.

    Any free database server you may suggest?
    IPT, Jun 30, 2004
    #7
  8. IPT wrote:
    > I'm not Serge.
    >
    > I use mySQL 4.0, does it support bookmark (.AbsolutePage)?


    I have no idea. One way to find out is to use the Supports method.
    http://msdn.microsoft.com/library/en-us/ado270/htm/mdmthsupports.asp

    http://msdn.microsoft.com/library/en-us/ado270/htm/mdprorecordcount.asp


    >
    > I used to use Ms Access, and has many functions. Since migrate to
    > mySQL, I need to modify many codes pertaning to SQL systax. I can't
    > use anymore saved queries, nested select, etc. Even the 'getdate()'
    > has changed to 'Now()'.
    >
    > Any free database server you may suggest?


    Why not MSDE?

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Jun 30, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vikas Yadav
    Replies:
    0
    Views:
    1,111
    Vikas Yadav
    Sep 9, 2003
  2. Replies:
    5
    Views:
    3,833
    Ray Costanzo [MVP]
    Sep 22, 2005
  3. Iain Porter
    Replies:
    7
    Views:
    207
    Iain Porter
    Jul 13, 2004
  4. Marathoner

    ADODB.Recordset as parm to Web Service

    Marathoner, Dec 28, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    149
    Dilip Krishnan
    Dec 29, 2004
  5. jl

    RS.RecordCount always returns -1

    jl, Aug 4, 2005, in forum: ASP General
    Replies:
    3
    Views:
    316
Loading...

Share This Page