• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 40
  • Last Modified:

Empty OR not empty recordset (Classic ASP/VBScript)

I know that if we want to check if a recordset is empty (no records found) we are doing like this:

If rst.BOF And rst.EOF Then

Open in new window


How I can do the exactly opposite? To check if the recordset has records?

How can we write
IS NOT BOF

Open in new window

and
IS NOT EOF?

Open in new window

0
Vasilis Dimitrakas
Asked:
Vasilis Dimitrakas
1 Solution
 
Fabrice LambertFabrice LambertCommented:
Hi,

Just negate the test:
If Not (rst.BOF And rst.EOF) Then
    '// recordset isn't empty
End If

Open in new window

But if you want to go further away, apply De Morgan's law (https://en.wikipedia.org/wiki/De_Morgan%27s_laws):
Not (A AND B) <==> Not A OR Not B
Not (A OR B) <==> Not A AND Not B
So the result will be:
If Not rst.BOF Or Not rst.EOF Then
    '// recordset isn't empty
End If

Open in new window

0
 
Vasilis DimitrakasAuthor Commented:
@Fabrice Lambert: Thank you for the in-depth analysis of your answer!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now