Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

response.redirect question 1

Status
Not open for further replies.

schase

Technical User
Sep 7, 2001
1,756
US
Hi all,

I really thought I had this licked, but it's operating wrong.

Right under the recordset I have this

<% IF (rs.Recordcount) <1 THEN
response.Redirect(&quot;errorpage.asp&quot;)
End If
%>

(I've also treid if (rs.Recordcount) = 0 THEN)

Now on the first page, it will goto the errorpage.asp if there are no records. on the errorpage they can select a new month/year and it will send to another identical page (but passing the querystring values along). First page works great, and I've got the code on the second page. But with the = 0 it will process like it has a record (if there are any records or not)- but the <1 will redirect to the errorpage if there is any records or not.

Any ideas?

Thank you &quot;Damn the torpedoes, full speed ahead!&quot;

-Adm. James Farragut

Stuart
 
try it this way
If rs.Recordcount < 1 THEN
You do not need () around conditional statements in vbscript (asp) unless you are performing a OR etc..
or is you are doing something of this fasion
If 1 > (1*1) THEN
I help at your own risk, if I brake it sorry! But if I fixed it, let me know with a
star.gif
[thumbsup2]
admin@onpntwebdesigns.com
 
Instead of using rs.Recordcount try using rs.BOF and rs.EOF to test whether you have an empty recordset

Code:
If ( rs.BOF AND rs.EOF ) Then
   Response.Redirect(&quot;errorpage.asp&quot;)
End If

When a recordset is empty both Beginning Of File and End Of File are true.
Recordcount requires rs.CursorLocation = 3 'adUseClient in order to obtain a valid record count;
otherwise it returns -1 meaning that the record count is not available.
 
perfect, thanks &quot;Damn the torpedoes, full speed ahead!&quot;

-Adm. James Farragut

Stuart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top