CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: recordset

  1. #1
    Join Date
    Jul 1999
    Location
    USA
    Posts
    101

    recordset

    How can I check if a recordset is empty or not. If not, I want to empty it before opening it.

    Thanks


  2. #2
    Join Date
    May 1999
    Location
    Bogotá, Colombia
    Posts
    37

    Re: recordset

    Are you using the ADODC recordset? If so then you could use the .RecordCount property to return the number of records. Then again, when an ADODC recordset is closed, it is empty anyway.


  3. #3

    Re: recordset

    If you want to check before it's open, you can run a query to check the count (e.g., "SELECT COUNT(*) AS MYCOUNT FROM MYTABLE"). If rs("MYCOUNT") = 0, there are no records.

    If you can open it first, you can either check the recordcount property, or if recordcount is not supported (e.g., on firehose cursors), you can use the following

    if rs.bof and rs.eof then
    'recordset has no reocords
    end if

    Charlie Zimmerman
    http://www.freevbcode.com


  4. #4
    Guest

    Re: recordset

    It depends upon how your Recordset was created. If you specify a static
    cursor on the Recordset.Open method then you will be able to use the
    RecordSet.RecordCount property. If you use any other cursor, RecordCount
    will always return -1.


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

Featured