Results 1 to 3 of 3

Thread: How can I know if a database is empty?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 1999
    Posts
    14
    The recordcount property doesn't work. I have values different from 0 even if the database is empty. And if I use .BOF I have an error!

    Thanks

  2. #2
    Addicted Member pardede's Avatar
    Join Date
    Jan 2000
    Posts
    232
    have you tried checking .eof ?

  3. #3

    .RecordCount is not accurate

    I have tried so many times to try and use .RecordCount for a recordset and it just is not consistent. I am assuming you are using ADO, but if not, it doesn't matter; same concept applies.

    Soo.... I have changed to doing a count of the records that would be returned with a regular recordset first, because it is very fast, and if I don't have to hit the database to get the big load of stuff, if I don't have to then, alrgight.

    What I'm saying is this... (Yes you may hit the DB twice), but it may be worth it.
    Code:
    "ssql = "Select Count(ID) From Names Where State = 'CA'"
    Use some field name that is in your table to simply get the number of records in the recordset. Don't use the Count(*) method because then it has to search the Fields collection of the database and examine all the fields. Then, use this
    Code:
    if ors.Fields(1) > 0 then
       ssql = Select ID, Last, First from Names Where State = 'CA'
       ors.open ssql, oConn, adforwardonly
       ...
    end if
    This will tell you how many records you have by, 1) not having to do a .MoveLast and open you RS in a non-forwardonly fashion, 2) it lets you make a decision.

    Hope the info helps for something.
    Senior Systems Architect/Programmer

Posting Permissions

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



Click Here to Expand Forum to Full Width