Sign in to follow this  

[web] ASP: What to do when query is empty

This topic is 4686 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a pretty basic question in regards to queries on an ASP page. I have a record that is getting pulled from the database, but if there are no records it throws an error (no BOF or EOF). It would seem though that I cannot say 'if recordid = nothing then go to an error page', since it SEEMS to then be complaining that recordid does not exist. When making a query, and in the case there are no records to display, should there be anything special I should be doing in order to stop it throwing a server error?

Share this post


Link to post
Share on other sites
just check to see if there is a record before you try to use em.

if rst.EOF = false then
use record
else
do something else.
end if

if the data is all spread out and your no simply looping the recordset.

do the check to see if there are records and set a boolean flag on the results

then every place you use a record from the recordset do a check using the flag.

it could be your not actually creating the right objects mind.

post your code if you want.

Share this post


Link to post
Share on other sites
Generally when I get information in a recordset I loop through it like so:


while( NOT objRst.EOF )
'stuff - basically you do anything you want to the current row of the
' recordset here, then the next iteration will take care of the next row,
' and so on...

objRst.movenext
wend


or when I'm really not expecting to use more than one record, I do something like:


if( NOT objRst.EOF ) then
'stuff to be done to current row in the recordset
end if


Hope that helps!

Share this post


Link to post
Share on other sites

This topic is 4686 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this