Just working on a search form and if no records are found I don't want to just have the table headers displayed with no records below, I would like to add a helpful message.
Is there a record count property I've forgotten about?
I've just created a variable that adds one to itself before the rs.MoveNext in the While loop then an If statement (RecordCount = 0) after the While loop that adds a table row with the message.
Is this the best way of doing this?
Alex
Reply from Richard Rost:
You could use the BOF property (beginning of file) and say something like this inside your loop:
if RS.BOF then ' display the table header end if
Or, as you suggested, you could use a Counter variable, that way you could say this at the end of your loop:
if MyCounter = 0 then response.write "There were no records to display" end if
The choice is yours. There IS a RecordCount property you can use for a recordset, but it's unreliable and it doesn't work with every cursor type. I avoid it.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Active Server Pages Forum.