redho home | products | services
Web Design Forums

Web Design Forums  


Web Hosting, Web Design, Software and Web Development Forums  
 FAQFAQ   MemberlistArchive  Log inLog in   RegisterRegister 
         

Why do I get 'BOF or EOF' errors?



 
Post new topic   Reply to topic    Web Design Forums -> ASP in depth
View previous topic :: View next topic  
Author Message
Mark
Guest




Why do I get 'BOF or EOF' errors?
  Reply with quote


Guest





When doing searches or other SQL queries, you may have encountered this error:

ADODB.Field error '80020009'

Either BOF or EOF is True, or the current record has been deleted; the
operation requested by the application requires a current record.

or

ADODB.Recordset error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.

The most probable cause, of course, is that there is no record. For example, it would happen with the following code, if none of the records cotnained 'frank' in the fname column:

Code:
<%
    set conn = CreateObject("ADODB.Connection")
    conn.open <connection string>
    set rs = conn.execute(<sql>)
    do while not rs.eof
        ' process
        rs.movenext
    loop
    ' ...
%>
 

To prevent this error from "blowing up" your ASP page, you need to trap for the case where no records are there. The easiest way to do this is by adding the following lines:

Code:
<%
    set conn = CreateObject("ADODB.Connection")
    conn.open <connection string>
    set rs = conn.execute(<sql>)
    if not rs.eof then
        do while not rs.eof
            ' process
            rs.movenext
        loop
    else
        response.write "No matches."
    end if
    ' ...
%>


If you are sure there are results, you might check that you at the most recent version of MDAC (which you can download from Microsoft Data Downloads). For more information, see KB #230101.

Another possible reason is that you are using a stored procedure that operates on a temp table, or does other row-affecting operation prior to your select statement. To get around this, issue the following at the beginning of your stored procedure:

SET NOCOUNT ON

This will prevent "(n) row(s) affected" messages from being interpreted by the provider as a resultset.

If you can't change the procedure, you can use trial and error to add the following statement in order to move to the correct and populated resultset:

Code:
<%
    set conn = CreateObject("ADODB.Connection")
    conn.open <connection string>
    set rs = conn.execute(<sql>)
    set rs = rs.nextRecordSet()
    ' ...
%>
  Reply with quote
Salvador



Joined: 23 Dec 2005
Posts: 5
Mark wrote:
Why do I get 'BOF or EOF' errors?


I think you should find something better to do with you time...
  Reply with quote
Page 1 of 1
Post new topic   Reply to topic    Web Design Forums -> ASP in depth


Dubai Forums - Expat Help | Vegan Chat | Java Programming | Free 3D tutorials and 3d textures | Paris Forum | EU Forum
Free Dubai Classifieds | Free London Classifieds | Jobs in London

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

Powered by phpBB © 2001, 2005 phpBB Group