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

I don't understand why I am getting an error

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I don't understand why I am getting a BOF or EOF error message. when I wasn't testing to see if Approve eqqualed 1 then the form worked, but now that I test this I get that error. Any suggestions. on my if statements.

Scott

<%dbrs.close %>
<%dbrs2.open (&quot;Select * From Timesheet where userID = '&quot; & request.form(&quot;employee&quot;)& &quot;' and month = '&quot; & request.form(&quot;month&quot;)& &quot;'&quot; ), dbconn, 0, 1 %>
<%Set RSCount = dbconn.Execute(&quot;SELECT Count(*) As NumRecs From Timesheet where userID = '&quot; & request.form(&quot;employee&quot;)& &quot;' and month = '&quot; & request.form(&quot;month&quot;)& &quot;'&quot; )%>
<%dbrs.open (&quot;Select * From employeeinfo where userID = '&quot; & request.form(&quot;employee&quot;)& &quot;'&quot;), dbconn, 0, 1 %>
<input type=&quot;text&quot; name=&quot;employee1&quot; readonly=&quot;true&quot; value=&quot;<%=Request.Form(&quot;employee&quot;)%>&quot;>
<input type=&quot;text&quot; name=&quot;month1&quot; readonly=&quot;true&quot; value=&quot;<%=Request.Form(&quot;month&quot;)%>&quot;>
<%dbrs2.movefirst %>
<% Do While NOT dbrs2.EOF %>
<%dbrs2.movenext %>
<% Loop %>

<% if dbrs2(&quot;approval&quot;).Value <> 1 Then %> // Error Message on EOF and BOF given here.

<table width=&quot;89%&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td>
<div align=&quot;center&quot;><b>Month</b></div>
</td>
<td>
<div align=&quot;center&quot;><b>Date</b></div>
</td>
<td>
<div align=&quot;center&quot;><b>Hours</b></div>
</td>
<td><b>Code</b></td>
</tr>
<%dbrs2.movefirst %>
<%
Dim y
y = 1
%>
<% Do While NOT dbrs2.EOF %>
<tr>
<td><%=(dbrs2.Fields.Item(&quot;month&quot;).Value)%></td>
<td><input type=&quot;text&quot; name=&quot;date<%=y%>&quot; value=&quot;<%=(dbrs2.Fields.Item(&quot;date&quot;).Value)%>&quot;></td>
<td>
<input type=&quot;text&quot; name=&quot;hour<%=y%>&quot; value=&quot;<%=(dbrs2.Fields.Item(&quot;hour&quot;).Value)%>&quot; onAfterUpdate=&quot;showAnswers()&quot;>
</td>
<td>
<input type=&quot;text&quot; name=&quot;code<%=y%>&quot; value=&quot;<%=(dbrs2.Fields.Item(&quot;code&quot;).Value)%>&quot; size=&quot;5&quot; onAfterUpdate=&quot;showAnswers()&quot;>
</td>
</tr>
<%dbrs2.movenext %>
<%y = y + 1%>
<% Loop %>
</table>

<table width=&quot;80%&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td width=&quot;33%&quot;>Personal Time:
<input type=&quot;text&quot; name=&quot;personaltime&quot; size=&quot;2&quot; maxlength=&quot;2&quot;>
</td>
<td width=&quot;32%&quot;>Overtime:
<input type=&quot;text&quot; name=&quot;overtime&quot; size=&quot;2&quot; maxlength=&quot;2&quot;>
</td>
<td width=&quot;35%&quot;>Vacation Time:
<input type=&quot;text&quot; name=&quot;vacationtime&quot; size=&quot;2&quot; maxlength=&quot;2&quot;>
<input type=&quot;hidden&quot; name=&quot;rscount&quot; value=&quot;<%Response.Write RSCount(&quot;NumRecs&quot;)%>&quot;>
</td>
</tr>
<tr>
<td width=&quot;33%&quot;>Jury or Witness Duty Leave:
<input type=&quot;text&quot; name=&quot;juryleave&quot; size=&quot;2&quot; maxlength=&quot;2&quot;>
</td>
<td width=&quot;32%&quot;>Medical Leave:
<input type=&quot;text&quot; name=&quot;medicalleave&quot; size=&quot;2&quot; maxlength=&quot;2&quot;>
</td>
<td width=&quot;35%&quot;>
<input type=&quot;hidden&quot; name=&quot;personal&quot; value=&quot;<%=(dbrs.Fields.Item(&quot;personalTime&quot;).Value)%>&quot;>
<input type=&quot;hidden&quot; name=&quot;vacation&quot; value=&quot;<%=(dbrs.Fields.Item(&quot;vacationtime&quot;).Value)%>&quot;>
<input type=&quot;hidden&quot; name=&quot;over_time&quot; value=&quot;<%=(dbrs.Fields.Item(&quot;overtime&quot;).Value)%>&quot;>
<input type=&quot;hidden&quot; name=&quot;firstname&quot; value=&quot;<%=(dbrs.Fields.Item(&quot;firstName&quot;).Value)%>&quot;>
<input type=&quot;hidden&quot; name=&quot;lastname&quot; value=&quot;<%=(dbrs.Fields.Item(&quot;lastName&quot;).Value)%>&quot;>
</td>
</tr>
</table>
<p>
<% If (Session(&quot;whosonline&quot;) = dbrs(&quot;supervisorID&quot;).value) or (Session(&quot;timelevel&quot;) > 2) Then %>
</p>
<p>To Approve This Time Sheet Please Check here
<input type=&quot;checkbox&quot; name=&quot;checkbox2&quot; value=&quot;1&quot;>
<input type=&quot;hidden&quot; name=&quot;approvedby&quot; value=&quot;<%=request.servervariables(&quot;AUTH_USER&quot;)%>&quot;>
<% End If %>
</p>
<p>
<input type=&quot;button&quot; name=&quot;showbutton&quot; value=&quot;Show Me The Totals&quot; onClick=&quot;showAnswers();this.form.showanswers.value='2'&quot;>

</p>
<p>
<input type=&quot;submit&quot; name=&quot;Update&quot; value=&quot;Update My Info&quot; onClick=&quot;showall()&quot;>
<input type=&quot;hidden&quot; name=&quot;Selected2&quot; value=&quot;1&quot;>
<% If (Session(&quot;whosonline&quot;) = dbrs(&quot;supervisorID&quot;).value) or (Session(&quot;timelevel&quot;) > 2) Then %>
<input type=&quot;submit&quot; name=&quot;Approve&quot; value=&quot;Approve This TimeSheet&quot; onClick=&quot;showall()&quot;>
<% End If %>
<% End If %>


<% if dbrs2(&quot;approval&quot;).Value = 1 Then %>

<table width=&quot;89%&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td>
<div align=&quot;center&quot;><b>Month</b></div>
</td>
<td>
<div align=&quot;center&quot;><b>Date</b></div>
</td>
<td>
<div align=&quot;center&quot;><b>Hours</b></div>
</td>
<td><b>Code</b></td>
</tr>
<%dbrs2.movefirst %>
<%
y = 1
%>
<% Do While NOT dbrs2.EOF %>
<tr>
<td><%=(dbrs2.Fields.Item(&quot;month&quot;).Value)%></td>
<td><%=(dbrs2.Fields.Item(&quot;date&quot;).Value)%></td>
<td>
<%=(dbrs2.Fields.Item(&quot;hour&quot;).Value)%>
</td>
<td>
<%=(dbrs2.Fields.Item(&quot;code&quot;).Value)%>
</td>
</tr>
<%dbrs2.movenext %>
<%y = y + 1%>
<% Loop %>
</table>

<p>
<% End If %>
<% End If %>
 
Hi Scott,

A couple of points which I hope will help steer you in the right direction:

(a) Why do you start of your code by Closing the dbrs recordset before you open it. I can only assume that their is some Serverside VBScript above the lines you provide, as I cant see where the dbrs recordset, or associated connection declarations.

(b) There is no need to include every statement in <% ... %> pairs. Your code becomes more compact and readable if you use single pairs of <% and %> to &quot;bracket&quot; MULTIPLE CONTIGUOUS Severside script lines; so, for example:

<% statement one %>
<% statement two %>
<% statement three %>

can more clearly be represented by:

<%
statement one
statement two
statement three
%>

I've added the spare lines for clarity.

(c) Now to answer your real question regarding why you are getting the EOF error:

The problem as you point out, is occuring in the following lines of code; I've added line numbers to help explain:

1 <%dbrs2.movefirst %>
2 <% Do While NOT dbrs2.EOF %>
3 <%dbrs2.movenext %>
4 <% Loop %>

5 <% if dbrs2(&quot;approval&quot;).Value <> 1 Then %> // Error Message on EOF and BOF given here.

The reason for the problem is as follows:

Line one moves you to the first record of the recordset
Lines 2 through 4 then loop you through every record in the recordset. The loop is terminated AFTER the last record has been visited. At this point EOF (stands for &quot;End of File&quot;) of the recordset has been reached.
Line 5 then fails, and produces the error, because the recordset has reached EOF, and so the &quot;approval&quot; field cannot be recovered; makes sense; we're not pointing to any particular record where an &quot;approval&quot; value can be retrieved; we're pointing &quot;beyond&quot; all of the records.

To resolve this problem, you essentially need to transfer your line 5 (plus other associated code) to between lines 2 and 3. This will allow you to iterate through the recordset, testing the approval field for each record, and based on the results, doing something else before moving on to the next record, and repeating the cycle.

(d) Taking into account my points (b) and (c), your code might look something like this:

<%
dbrs2.movefirst
Do While NOT dbrs2.EOF
if dbrs2(&quot;approval&quot;).Value <> 1 Then
... do stuff in here
End If
dbrs2.movenext 'note use of indentation
Loop
%>

Be aware that you can only use the <% %> technique above where the script lines are contiguous. If you wish to embed HTML, then you'll have to close and then re-open the script brackets.

You might also want to investigate the Response.Write command, which will allow you to write the HTML commands from within the Serverside script.

I hope that this helps,

Cheers,
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top