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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Empty Recordset Message

Status
Not open for further replies.

kaycee79

Technical User
Jan 10, 2004
82
GB
Empty Recordset

I have the code below that produces a list of events from the database. If the database does not contain any events, I am getting the error message below;

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

How can I create a message on the screen saying ‘There are no events to write reports on’?

Thanks in advance

<%
Option Explicit
Dim StrConnect
%>

<!-- #INCLUDE FILE=&quot;ProjectConnection.asp&quot; -->



<HTML>
<HEAD>
<TITLE>Add Event Report</TITLE>
</HEAD>
<BODY>


<p align=&quot;center&quot;><u><b><font size=&quot;7&quot;>Add an Event Report</font></b></u></p>
<BR>
<%
Dim objRS
Set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
objRS.Open &quot;Events&quot;, strConnect, 3,3
objRS.MoveFirst
%>

Event Name
<FORM ACTION = &quot;addreporttodb.asp&quot; METHOD= &quot;post&quot;>

<SELECT NAME=&quot;EventName&quot; SIZE=&quot;1&quot;>

<%
Do While NOT objRS.EOF
Response.Write &quot;<OPTION VALUE='&quot; & objRS(&quot;Event Name&quot;) & &quot;'>&quot;
Response.Write objRS(&quot;Event Name&quot;) & &quot;</OPTION>&quot;
objRS.MoveNext
Loop
objRS.Close
Set objRS = Nothing
%>
</SELECT>




<P>Date<input type=&quot;text&quot; name = &quot;txtDate&quot; size=&quot;20&quot;><BR>
Report<BR>
<textarea name=&quot;txtReport&quot; col=&quot;200&quot; rows=&quot;12&quot; wrap=&quot;virtual&quot; cols=&quot;40&quot;></textarea> <BR>
Username <input type=&quot;text&quot; name = &quot;txtUsername&quot; size=&quot;20&quot;><BR>


<INPUT TYPE=&quot;SUBMIT&quot; VALUE=&quot;Submit&quot;><BR>
<a href=&quot;usereventreport.asp&quot;>Event Report</a>
</form>
</body>
</html>
 
This would be the line thats causing the error.

objRS.MoveFirst

movefirst is the default value for this recordset object.

you could either remove the line

or place

if objRS.Eof then
response.write &quot;No Records Found&quot;
Else

above it

and below Set objRS = Nothing

end if

Hope this helps

Simon
 
do you mean MoveNext? because there is no MoveFirst
 
you typed it :

<%
Dim objRS
Set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
objRS.Open &quot;Events&quot;, strConnect, 3,3
objRS.MoveFirst
%>


 
oh yeah,i see that now, i got it workin, thanks alot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top