PDA

Click to See Complete Forum and Search --> : BOF or EOF is true ERROR


Brandito
Mar 13th, 2001, 10:31 PM
Hi,

I am coding a search engine and message board in .ASP. The problem is I get this error:

Error Type:
ADODB.Field (0x80020009)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

I have tracked it down to this:

<%
while not rs.eof

%> <tr><td><a href="<% =rs("location") %>"> <% =rs("iteam") %> </a></td>
<td bgcolor="beige"> <% =rs("text") %> </td></tr>
<% rs.movenext

wend %>

That code is ran "if not (rs.eof) then".

Here is my Set statement:

set conn = server.createobject("adodb.connection")
conn.open "dsn=search"

set rs = conn.execute(SQL_String)

I have used this code before. I don't know what is up. I am running it on an access2000 database on iis 5.0 in IE 5.0. I don't understand how to fix it. Obviously there has to be data in the record set or the code would not even run because of my If statement!!

If you can help I would appreciate it,
Brandon

Active
Mar 14th, 2001, 12:28 AM
This is Strange...Indeed.

Well then ...try this Way..


While Not (rs.EOF or rs.BOF)
.....

Wend

JayWms
Mar 14th, 2001, 05:21 AM
Well, here are a couple comments on what I would do if I were you...

First of all, who uses a WHILE....WEND Loop?? okay.. that was just mean.. but for reals, that is not a good loop..

Okay.. here goes a new method to your looping...

RS.Open.... -Get your records

IF RS.Recordcount > 0 THEN
RS.MoveFirst
For i = 0 to RS.Recordcount

'Do Your Stuff Here
RS.MoveNext
Next
END IF

Shafee
Mar 14th, 2001, 11:57 AM
Here is the solution to your problem:


If rs.eof = True and rs.bof = True Then
Response.Write "There are no records to show."
Response.End
Else
Response.Write "<table>"
Response.Write "<tr>"
For each fld in rs.Fields
Response.Write "<th>" & fld.Name & "</th>"
Next
Response.Write "</tr>"
Do
Response.Write "<tr>"
For each fld in rs.Fields
Response.Write "<td>" & fld.Value & "</td>"
Next
Response.Write "</tr>"
Loop Until rs.Eof = True
Response.Write "</table>"
End If


You are getting that error because when there are no records in your recordset, both the eof and bof are true.

Brandito
Mar 14th, 2001, 12:18 PM
Thanx,

I am going to try this stuff out when I get off work.
I am hoping the "while not (rs.eof or rs.bof)" will work because I am pretty la-Z.

It is still strange though. It worked on my work server. But when I tampered with it at my house it blew up.

Talk 2 u l8r,
Brandon