Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

BOF EOF Error

Posted on 2005-04-18
5
Medium Priority
?
367 Views
Last Modified: 2012-06-27
Hi,
 I am developing a website that access's a Microsoft Access database. This error occurs when i try to update the database. This is included as part of a modify. So the form comes up with what was previoulsy in the database for a particular name and then changes are made and it is submitted.

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

The strange thing is that i am using nearly the exact same code for the add function and that is working fine. It is really annoing me. Any help would be greatly appreciated.

Thanks,
Jonathan
0
Comment
Question by:screach
  • 2
  • 2
5 Comments
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 13810735
Please post you code
0
 

Author Comment

by:screach
ID: 13810782
Hi,
The three pages are modify_access_select.asp, modify_access_form.asp and modify_access_entry.asp. I don't think there is any problem with select just the link between the form and modify entry.

Thanks,

MODIFY_ACCESS_SELECT

<%
'If the session variable is False or does not exsist then redirect the user to the unauthorised user page
If Session("blnIsUserGood_1") = False or IsNull(Session("blnIsUserGood_1")) = True then
      'Redirect to unathorised user page
      Response.Redirect"unauthorised_user_page_modify.htm"
End If
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>modify_access_select</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<h1 align="center">Modify Select</h1>


<%
'Dimension variables
Dim adoCon                   'Holds the Database Connection Object
Dim rsAccess                  'Holds the recordset for the records in the database
Dim strSQL                  'Holds the SQL query for the database
Dim filePath
Dim docHolder

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
filePath = Server.MapPath("database.mdb")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=letmein; DBQ=" & filePath

'Create an ADO recordset object
Set rsAccess = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT DoorAccess.* FROM DoorAccess;"

'Open the recordset with the SQL query
rsAccess.Open strSQL, adoCon
%>

<table width="778" border="1" cellspacing="0" cellpadding="1" bgcolor="#ffffff" background="">
  <tr bgcolor="#4060a0">
    <th width="118" align="left"><font face="Verdana" color="#ffffff" size="2">NAME </align></th>
    <th width="318" align="left"><font face="Verdana" color="#ffffff" size="2">DOOR1      </align>
    </th>
    <th width="328" align="left"><font face="Verdana" color="#ffffff" size="2">
      <div align="center">DOOR2 </align> </div></th>

  </tr>
  <%
'Loop through the recordset
Do While not rsAccess.EOF
%>
<tr>
      <td bgcolor="#fff7de"><% Response.Write("<a href=""modify_access_form.asp?ID="& rsAccess("ID")&""">")%>
                                <% Response.Write(rsAccess("Name"))%>
                                    <% Response.Write("</a>")%> </td>  
                        <td bgcolor="#fff7de"><% Response.Write(rsAccess("Door1"))%></td>                  
                        <td bgcolor="#fff7de"><% Response.Write(rsAccess("Door2"))%></td>            
                        
                                    </tr>
 
  <%
'Loop
      rsAccess.MoveNext
Loop
%>
</table>            

<%
'Reset server objects
rsAccess.Close
Set rsAccess = Nothing
Set adoCon = Nothing
%>                                          
<TABLE WIDTH="968" BORDER="0" CELLPADDING="0" CELLSPACING="0" ID="Table5">
                  <TR>
                        
    <TD COLSPAN="3" BGCOLOR="#FFFFFF"><img src="./gfx/spacer.gif" width="780" height="56" /></TD>
                  </TR>
                  
                  <TR>
                        
    <TD><IMG SRC="./gfx/vbl_02.gif" WIDTH="907" HEIGHT="12" /></TD>
                  </TR>
                  
                  <TR>
                        <TD COLSPAN="3" BGCOLOR="#FFFFFF" WIDTH="968" HEIGHT="42">
                        
                              <TABLE WIDTH="967" BORDER="0" CELLPADDING="0" CELLSPACING="0" ID="Table6">
        <tr>
                                          <td width="967" align="middle"><div align="center"><span class="text">
              &#160;<span class="text"><a class="surround" href="./main.asp"  onmouseover="window.status='Go to start of iButton Site';return true;" onmouseout="window.status='';return true;">Home</a></span>      
                                  |&#160;<a class="surround" href="/main_modify.asp" onmouseover="window.status='Main iButton Website';return true;" onmouseout="window.status='';return true;">Modify Home</a>&#160;  
                    |&#160;<a class="surround" href="mailto:0128686@student.ul.ie.ie" onmouseover="window.status='Click here to contact WebSite Administrator';return true;" onmouseout="window.status='';return true;">Contact
              Administrator</a>&#160; |&#160;<a class="surround" href="http://www.iButton.com" onmouseover="window.status='Main iButton Website';return true;" onmouseout="window.status='';return true;">iButton
              Information</a>&#160; |&#160;<a class="surround" style="cursor:hand" href="#" onclick="this.style.behavior='url(#default#homepage)';this.setHomePage(window.location);" onmouseover="window.status='Make this browser start page';return true;" onmouseout="window.status='';return true;">Make
              this my Home Page</a> </span> </div></td>
                                    </tr>
                              </TABLE>
                        </TD>
                  </TR>
            </TABLE>      
</body>
</html>




MODIFY_ACCESS_FORM.ASP

<%
'If the session variable is False or does not exsist then redirect the user to the unauthorised user page
If Session("blnIsUserGood_1") = False or IsNull(Session("blnIsUserGood_1")) = True then
      'Redirect to unathorised user page
      Response.Redirect"unauthorised_user_page_modify.htm"
End If
%>


<% 'Dimension variables
Dim adoCon                                      'Holds the Database Connection Object
Dim rsModifyEntry                   'Holds the recordset for the record modified
Dim strSQL                                     'Holds the SQL query to query the database
Dim IngRecordNo                         'Holds the record number to be deleted
Dim filePath

'Read in the Name to be modified
IngRecordNo = CLng(Request.QueryString("ID"))

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
filePath = Server.MapPath("database.mdb")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=letmein; DBQ=" & filePath

'Create and ADO recordset object
Set rsModifyEntry = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT DoorAccess.* FROM DoorAccess WHERE ID=  " & IngRecordNo


'Open the recordset with the SQL query
rsModifyEntry.Open strSQL, adoCon
%>  

<html>
<head>
<title>Modify Access</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body bgcolor="#FFFFFF" text="#000000">
<div align="center">
  <table width="518" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
      <td align="center"> <h1 align="center"> Modify Access</h1></td>
    </tr>
  </table>
<p>&nbsp;</p></div>
</head>

<script language="JavaScript" type="text/javascript">
<!--

function validate(frm) {
  var state = true
      
      if(frm.Name.value.length == 0) {
        state = false
            alert("Please supply an NAME")
            frm.Name.focus()
      }
      
      else if(frm.Door1.value.length < 64 && frm.Door2.value.length < 64) {
        state = false
            alert("You must include at least one serial number longer than 64 characters")
            frm.Door1.focus()
      }
      else if(state == true) {
        alert("File has been successfully added to the iButton Database!")
      }
      
      return state
}
//-->
</script>

<body link="#FFFFFF" vlink="#FF00FF">

<!-- MAIN TABLE ---------------------------------------------------------------------------------------------------->

      <table border="0" cellspacing="0" cellpadding="0">
        <tr valign="top">
      
          <td><img src="gfx/helpers/spacer.gif" width="30" height="5"></td>
         
  <td>
    <!-- This allows the text to go to the RHS of FUJISAWA Logo -->
    <table width="54%" border=0 align="center" cellpadding=0 cellspacing=0 bgcolor=#0c2d83>
      <tbody>
        <tr valign=top align=left>
          <td valign=top align=left> </td>
        </tr>
        <tr valign=top align=left>
          <td valign=top align=left bgcolor=#FFFFFF> <table width="99%" height="187" border=0 align="center" cellpadding=5 cellspacing=1 bgcolor=#0c2d83 >
              <tbody>
                <tr>
                  <td class=BodyTextBoldWhite bgcolor=#7f9bc7 colspan=2> <div align="center"><b>
                     MODIFY ACCESS</b> </div></td>
                </tr>
                         <form ACTION="modify_access_entry.asp" METHOD="POST" NAME="MyForm" onSubmit="return validate(MyForm)">
           
              <TR class=TreeSubBlue vAlign=Default align=Default>
         <TD class=TreeSubBlue bgColor=#ffffff width=100><font face="Verdana"><b>Name</b>                         </TD>
         <TD class=TreeSubBlue bgColor=#ffffff width=100><input type ="text" name="Name" maxlength="50" value="<% =rsModifyEntry("Name")%>"> </TD>
        </TR>
               
                        
        <TR class=TreeSubBlue vAlign=Default align=Default>
         <TD class=TreeSubBlue bgColor=#ffffff width=100><font face="Verdana"><b>Door 1 Serial Number</b>                         </TD>
         <TD class=TreeSubBlue bgColor=#ffffff width=100><input type ="text" name="Door1" maxlength="64" value="<% =rsModifyEntry("Door1")%>"> </TD>
        </TR>
               
        <TR class=TreeSubBlue vAlign=Default align=Default>
         <TD class=TreeSubBlue bgColor=#ffffff width=100><font face="Verdana"><b>Door 2 Serial Number</b>                         </TD>
         <TD class=TreeSubBlue bgColor=#ffffff width=100><input type ="text" name="Door2" maxlength="64" value="<% =rsModifyEntry("Door2")%>"> </TD>
        </TR>
               
             
                      <tr class=TreeSubBlue valign=Default align=Default>
                  <td class=TreeSubBlue bgcolor=#ffffff colspan=2> <input type="submit" name="submit" value="Submit">
                    <img src="gfx/helpers/spacer.gif" width="382" height="8">
                    <input type="reset" name="Reset" value="Reset"> </td>
                </tr>
              </tbody>
                        </form>       
            </table></td>
        </tr>
      </tbody>
    </table>


<TABLE WIDTH="968" BORDER="0" CELLPADDING="0" CELLSPACING="0" ID="Table5">
                  <TR>
                        
    <TD COLSPAN="3" BGCOLOR="#FFFFFF"><img src="./gfx/spacer.gif" width="780" height="56" /></TD>
                  </TR>
                  
                  <TR>
                        
    <TD><IMG SRC="./gfx/vbl_02.gif" WIDTH="907" HEIGHT="12" /></TD>
                  </TR>
                  
                  <TR>
                        <TD COLSPAN="3" BGCOLOR="#FFFFFF" WIDTH="968" HEIGHT="42">
                        
                              <TABLE WIDTH="967" BORDER="0" CELLPADDING="0" CELLSPACING="0" ID="Table6">
        <tr>
                                          <td width="967" align="middle"><div align="center"><span class="text">
              &#160;<span class="text"><a class="surround" href="./main.asp"  onmouseover="window.status='Go to start of iButton Site';return true;" onmouseout="window.status='';return true;">Home</a></span>      
                                  |&#160;<a class="surround" href="/main_modify.asp" onmouseover="window.status='Main iButton Website';return true;" onmouseout="window.status='';return true;">Modify Home</a>&#160;  
                    |&#160;<a class="surround" href="mailto:0128686@student.ul.ie.ie" onmouseover="window.status='Click here to contact WebSite Administrator';return true;" onmouseout="window.status='';return true;">Contact
              Administrator</a>&#160; |&#160;<a class="surround" href="http://www.iButton.com" onmouseover="window.status='Main iButton Website';return true;" onmouseout="window.status='';return true;">iButton
              Information</a>&#160; |&#160;<a class="surround" style="cursor:hand" href="#" onclick="this.style.behavior='url(#default#homepage)';this.setHomePage(window.location);" onmouseover="window.status='Make this browser start page';return true;" onmouseout="window.status='';return true;">Make
              this my Home Page</a> </span> </div></td>
                                    </tr>
                              </TABLE>
                        </TD>
                  </TR>
            </TABLE>      
</body>
</html>





MODIFY_ACCESS_ENTRY.ASP
 
<%
'If the session variable is False or does not exsist then redirect the user to the unauthorised user page
If Session("blnIsUserGood_1") = False or IsNull(Session("blnIsUserGood_1")) = True then
      'Redirect to unathorised user page
      Response.Redirect"unauthorised_user_page_modify.htm"
End If
%>


<% 'Dimension variables
Dim adoCon                                      'Holds the Database Connection Object
Dim rsUpdateEntry                   'Holds the recordset for the record to be modified
Dim strSQL                                     'Holds the SQL query to query the database
Dim RecMod                         'Holds the record number to be modified
Dim filePath

'Read in the ID to be Modified
RecMod = CLng(Request.QueryString("ID"))

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
filePath = Server.MapPath("database.mdb")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=letmein; DBQ=" & filePath

'Create and ADO recordset object
Set rsUpdateEntry = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT DoorAccess.* FROM DoorAccess WHERE ID=  " & RecMod

'Set the lock type so that the record is locked by ADO when it is deleted
rsUpdateEntry.LockType = 3

'Open the recordset with the SQl query
rsUpdateEntry.Open strSQL, adoCon


'Add a new record to the recordset
rsUpdateEntry.Fields("Name") = Request.Form("Name")
rsUpdateEntry.Fields("Door1") = Request.Form("Door1")
rsUpdateEntry.Fields("Door2") = Request.Form("Door2")

'Write the updated recordset to the database
rsUpdateEntry.Update

'Reset server objects
rsUpdateEntry.Close
Set rsUpdateEntry = Nothing
Set adoCon = Nothing

'Redirect to the modify_access_form.asp page
Response.Redirect "modify_access_form.asp"
%>
0
 
LVL 29

Accepted Solution

by:
rdivilbiss earned 450 total points
ID: 13811262
Have you performed any tests to verify that you received a record from your select before you try to modify the recordset?

'Open the recordset with the SQl query
rsUpdateEntry.Open strSQL, adoCon

if rsUpdateEntry.EOF and rsUpdateEntry.BOF then
    response.write "No records"
    response.end
end if

'Add a new record to the recordset
rsUpdateEntry.Fields("Name") = Request.Form("Name")
rsUpdateEntry.Fields("Door1") = Request.Form("Door1")
rsUpdateEntry.Fields("Door2") = Request.Form("Door2")


Assuming you do have a valid recordset, I always get an error if I perform a select then attemt to perform another action with the same open database connection while using MS Access.  (Not with mySQL or MS SQL, just Access.)

You might try closing the connection after you retrieve the recordset then open a new connection for the update.

Rod
0
 
LVL 6

Expert Comment

by:Samer Chidiac
ID: 13822372
That's a valid answer rdivilbiss ..

you might also do the Testing just b4 your loop

like

if not rst.eof then

   do while not rst.eof
   
   ......
   
   rst.movenext
   loop

else

    response.write "No records"
    response.end

end if


Cheers,

SC

----------
Samer Chidiac
Microsoft MVP - ASP / ASP.net
0
 

Author Comment

by:screach
ID: 13852964
I still couldn't find the problem so i instead of using update i just deleted and add a new record and that works fine.
Thanks,
Screach
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
By following these Magento e-commerce development tips, you can increase your website's conversion and profitability. Read this post for more details.
This video teaches users how to migrate an existing Wordpress website to a new domain.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month14 days, 3 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question