Why RS.recordcount returns only -1 ??

Results 1 to 3 of 3

Thread: Why RS.recordcount returns only -1 ??

  1. #1
    Join Date
    Dec 1969
    Posts
    119

    Default Why RS.recordcount returns only -1 ??

    I am trying to retrieve some data from the database and collect in the recordset. When I use <BR>select count(*) from TABLE<BR>num = RS(0)<BR> the num gives me exact number of records.<BR>If I use <BR>select * from TABLE and get the result in Recordset RS and ask<BR>num = RS.recordcount<BR>It always returns -1. Any reasons?<BR><BR>Thanks.<BR>Arvind

  2. #2
    Ed Guest

    Default RE: Why RS.recordcount returns only -1 ??

    My guess is that you are opening the recordset implicitly (ie. conn.Execute). When you do this, the recordset has a default cursor type of ForwardOnly. ForwardOnly recordsets always return a value of -1.<BR><BR>Instead, you might try this:<BR>rs.Open sql, conn, adOpenStatic

  3. #3
    Join Date
    Dec 1969
    Posts
    119

    Default RE: Why RS.recordcount returns only -1 ??

    Ed, right since the start, I have been using the code that you have suggested. Still the same problem persists. Meanwhile I am using only the count(*) thing.<BR>Thank you very much.<BR>Arvind

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •