Forums

ASP

This topic is locked

Either BOF or EOF is True Error message

Posted 25 Nov 2003 12:33:13
1
has voted
25 Nov 2003 12:33:13 Jay Eire posted:
Hi everyone,
i have a page with two recordsets reading to a page, if a recordset is empty i want it to display an error message, ive used a server behaviour in MX to do this but im getting the below error.
Any Ideas please?
Thanks
Jay

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

line 188 is =(Rs11.Fields.Item("t11".Value) which is the empty record set.




Here Is my Code:
<!--#include file="../Connections/Connect_to_database.asp" -->

var Rs11 = Server.CreateObject("ADODB.Recordset";
Rs11.ActiveConnection = MM_Connect_to_database_STRING;
Rs11.Source = "SELECT b.Name as EmpName, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20 FROM dbo.tbl_Kalender a join dbo.tbl_emp b on a.EmpID = b.EmpID WHERE (t11 = 'LunchTime')";
Rs11.CursorType = 0;
Rs11.CursorLocation = 2;
Rs11.LockType = 1;
Rs11.Open();
var Rs11_numRows = 0;


var Rs12 = Server.CreateObject("ADODB.Recordset";
Rs12.ActiveConnection = MM_Connect_to_database_STRING;
Rs12.Source = "SELECT b.Name as EmpName, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20 FROM dbo.tbl_Kalender a join dbo.tbl_emp b on a.EmpID = b.EmpID WHERE (t12 = 'LunchTime')";
Rs12.CursorType = 0;
Rs12.CursorLocation = 2;
Rs12.LockType = 1;
Rs12.Open();
var Rs12_numRows = 0;





<table width="53%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#666666">
<tr>
<td class="body"><div align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr class="body">
<td width="87%"><div align="center"></div></td>
</tr>
<tr>
<td><span class="body">=(Rs11.Fields.Item("t11".Value)</span><br>
if (Rs11.EOF && Rs11.BOF) {
<table width="119" border="1" cellpadding="0" cellspacing="0" bordercolor="#CC3300" class="body">
<tr>
<td><div align="center"><strong>Not Selected</strong></div>
</td>
</tr>
</table>
} // end Rs11.EOF && Rs11.BOF
</td>
</tr>
<tr>
<td><span class="body">=(Rs12.Fields.Item("t12".Value)</span><br>
if (Rs12.EOF && Rs12.BOF) {
<table width="119" border="1" cellpadding="0" cellspacing="0" bordercolor="#CC3300" class="body">
<tr>
<td><div align="center"><strong>Not Selected</strong></div>
</td>
</tr>
</table>
} // end Rs12.EOF && Rs12.BOF
</td>
</tr>
<tr>
<td><img src="../images/spacer.gif" width="190" height="1"></td>
</tr>
</table>
</div></td>
</tr>
</table>


Rs11.Close();


Rs12.Close();

Replies

Replied 02 Dec 2003 22:52:18
02 Dec 2003 22:52:18 Charles Beaudry replied:
The problem is that you're asking the variable to be displayed unconditionally when there is no value in that recordset.

The code of line you have:

<pre id=code><font face=courier size=2 id=code>&lt;td&gt;&lt;span class="body"&gt;=(Rs11.Fields.Item("t11".Value)&lt;/span&gt;&lt;br&gt;
if (Rs11.EOF && Rs11.BOF) {
&lt;table width="119" border="1" cellpadding="0" cellspacing="0" bordercolor="#CC3300" class="body"&gt;
&lt;tr&gt;
&lt;td&gt;&lt;div align="center"&gt;&lt;strong&gt;Not Selected&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
} // end Rs11.EOF && Rs11.BOF
&lt;/td&gt;
</font id=code></pre id=code>


The code trying to retrieve that value but there is none. That is why you are getting the error.

The code should be changed to:

<pre id=code><font face=courier size=2 id=code>
&lt;td&gt;&lt;span class="body"&gt;
&lt;table width="119" border="1" cellpadding="0" cellspacing="0" bordercolor="#CC3300" class="body"&gt;
&lt;tr&gt;
&lt;td&gt;&lt;div align="center"&gt;&lt;strong&gt;
&lt;% if (Rs11.EOF && Rs11.BOF) then %&gt;
Not Selected
&lt;% else %&gt;
&lt;%=(Rs11.Fields.Item("t11".Value)%&gt;
&lt;% end if %&gt;
&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/td&gt;
</font id=code></pre id=code>

Edited by - cbeaudry on 02 Dec 2003 22:54:26

Reply to this topic