PDA

View Full Version : How to redirect on no records


dawilis
09-01-2002, 11:53 AM
If my query has returns no records in the database how can I redirect the page to another page
I have tried this

<%
If RSVoucher.Fields.Item("id").Value = 0 Then
response.redirect"novoucher.asp"
End if
%>

but I get this error

Error Type:
ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/class/showvoucher.asp, line 96

Zvona
09-01-2002, 12:01 PM
Originally posted by dawilis

> <%
> If RSVoucher.Fields.Item("id").Value = 0 Then
> response.redirect"novoucher.asp"
> End if
> %>

(clearing the syntax)
<%
If RSVoucher.Fields.Item("id").Value = 0 Then
Response.Redirect("novoucher.asp")
End If
%>

> Error Type:
> ADODB.Field (0x800A0BCD)
> Either BOF or EOF is True, or the current record has been
> deleted. Requested operation requires a current record.
> /class/showvoucher.asp, line 96

Recordset contains no records or you've looped it to the end. You should check that at first. There's moveFirst() method for getting at the begin of recordset.

dawilis
09-01-2002, 12:03 PM
Thanks for your help
Fixed

raf
09-02-2002, 09:16 AM
i always use

if rsVoucher.EOF=true then
response.redirect("url")
else
'your commands for the records in your recordset
end if