Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

EOF BOF error classic asp

Posted on 2016-08-25
8
Medium Priority
?
71 Views
Last Modified: 2016-08-25
Hi all,

I have a system where I can give out tasks using text messages. If a task has a given user assigned, he gets a text-message. However, tasks are created without assigning it to a user - meaning that the value is empty. I have some code that queries who an assignment has been given to, but if it hasn't been given to anyone, I get the following error:
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

Here's the code:
CaseID = RSDatabase("CaseID")
 Assigned= RSDatabase("Assigned")

  If status = 1 then status_nr = "<td valign=center align=center bgcolor=FF0000><font color=ffffff><b>Status</b><br>Recieved</font></TD>"
  If status = 2 then status_nr = "<td valign=center align=center bgcolor=FFFF00><b>Status</b><br>See comments</TD>"
  If status = 23 then status_nr = "<td valign=center align=center bgcolor=009933><font color=ffffff><b>Status</b><br><font color=ffffff>Done</font></TD>"
  If status = 24 then status_nr = "<td valign=center align=center bgcolor=FFFFFF><font color=ff0000><b>Status</b><br>Rejected</TD>"

  DIM mySQL6, objRS6
  mySQL6 = "SELECT User, Name FROM Users WHERE User = '" & assigned & "'"
  Set objRS6 = Server.CreateObject("ADODB.Recordset")
  objRS6.Open mySQL6, strConnect


  DIM strUser
  strUser = objRS6("User")
  strName = objRS6("name")


If Assigned <> "" Then
show_assigned = "<br><font color='#FF0000'><b>Task assigned to " & strName & "</br></font>"
End if

Open in new window


Probably a simple solution I just can't get my head around.
0
Comment
Question by:micamb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 41770028
Add a test in your code.

if not RSDatabase.bof or not RSDatabase then ' run the code

CaseID = RSDatabase("CaseID")
 Assigned= RSDatabase("Assigned")

  If status = 1 then status_nr = "<td valign=center align=center bgcolor=FF0000><font color=ffffff><b>Status</b><br>Recieved</font></TD>"
  If status = 2 then status_nr = "<td valign=center align=center bgcolor=FFFF00><b>Status</b><br>See comments</TD>"
  If status = 23 then status_nr = "<td valign=center align=center bgcolor=009933><font color=ffffff><b>Status</b><br><font color=ffffff>Done</font></TD>"
  If status = 24 then status_nr = "<td valign=center align=center bgcolor=FFFFFF><font color=ff0000><b>Status</b><br>Rejected</TD>"

  DIM mySQL6, objRS6
  mySQL6 = "SELECT User, Name FROM Users WHERE User = '" & assigned & "'"
  Set objRS6 = Server.CreateObject("ADODB.Recordset")
  objRS6.Open mySQL6, strConnect


  DIM strUser
  strUser = objRS6("User")
  strName = objRS6("name")


If Assigned <> "" Then
show_assigned = "<br><font color='#FF0000'><b>Task assigned to " & strName & "</br></font>"
End if

else  ' if not RSDatabase.bof or not RSDatabase then ' run the code
   
    response.write "No Data"

end if  'if not RSDatabase.bof or not RSDatabase then ' run the code

Open in new window

0
 

Author Comment

by:micamb
ID: 41770055
Thanks for the input!
Result: Type mismatch, Line 37

Here's the full code:
<!--#include file="db/database_read.inc"--><!--#include file="close_access.inc"--><!--#include file="Include/link.inc"-->
  2 
  3 <html>
  4 
  5 <head>
  6 <!--#include file="Include/meta.asp"-->
  7 </head>
  8 <body><div data-role="page">
  9 
 10   <div data-role="header">
 11     <h1>Update your task</h1>
 12   </div><%
 13     Id = Request.querystring("Id")
 14   %>
 15 <%   Set DATABASE = Server.CreateObject("ADODB.Connection")
 16     DATABASE.Open strConnect
 17 
 18 SQLStr = "SELECT * FROM Tasks WHERE Id = '" &  Id & "' "
 19   Set RSDatabase = DATABASE.Execute(SQLStr)
 20 
 21 
 22  
 23   Id =  RSDatabase("Id")
 24   Name=  RSDatabase("Name")
 25   Email =  RSDatabase("Email")
 26   Tlf =  RSDatabase("tlf")
 27   TaskType =  RSDatabase("TaskType")
 28   Institution =  RSDatabase("Institution")
 29   Location=  RSDatabase("Location")
 30   Priority = RSDatabase("Priority")
 31   Description = RSDatabase("Description")
 32   DateR = RSDatabase("DateR")
 33   DateU = RSDatabase("DateU")
 34   Comments = RSDatabase("Comments")
 35   Status = RSDatabase("Status")
 36CaseID = RSDatabase("CaseID")
 37 if not RSDatabase.bof or not RSDatabase then
 38 Assigned = RSDatabase("Assigned")
 39 
 40   If status = 1 then status_nr = "<td valign=center align=center bgcolor=FF0000><font color=ffffff><b>Status</b><br>Recieved</font></TD>"
 41   If status = 2 then status_nr = "<td valign=center align=center bgcolor=FFFF00><b>Status</b><br>See comments</TD>"
 42   If status = 23 then status_nr = "<td valign=center align=center bgcolor=009933><font color=ffffff><b>Status</b><br><font color=ffffff>Completed</font></TD>"
 43   If status = 24 then status_nr = "<td valign=center align=center bgcolor=FFFFFF><font color=ff0000><b>Status</b><br>Rejected</TD>"
 44 
 45 
 46 
 47   DIM mySQL6, objRS6
 48   mySQL6 = "SELECT User, Name FROM Users WHERE User = '" & assigned & "'"
 49   Set objRS6 = Server.CreateObject("ADODB.Recordset")
 50   objRS6.Open mySQL6, strConnect
 51 
 52   DIM strUser
 53   strUser = objRS6("User")
 54   strName = objRS6("Name")
 55 
 56 
 57 If Assigned <> "" Then
 58 show_assigned = "<br><font color='#FF0000'><b>Task is assigned " & strName & "</br></font>"
 59 End if
 60 
 61 else  ' if not RSDatabase.bof or not RSDatabase then ' run the code
 62    
 63     response.write "No Data"
 64 
 65 end if  'if not RSDatabase.bof or not RSDatabase then ' run the code
 66 %>

Open in new window

0
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 41770075
if not RSDatabase.bof or not RSDatabase then

should be

if not RSDatabase.bof or not RSDatabase.eof then

probably better to use

if not RSDatabase.bof AND not RSDatabase.eof then


Lastly, this test needs to go before you use it as in line 22.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Assisted Solution

by:micamb
micamb earned 0 total points
ID: 41770092
Thanks for your effort so far and for putting up with my apparent lack of coding knowledge.

I did as suggested and got this error:
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
Line 52
Updated code below
<!--#include file="db/database_read.inc"--><!--#include file="close_access.inc"--><!--#include file="Include/link.inc"-->
  2 
  3 <html>
  4 
  5 <head>
  6 <!--#include file="Include/meta.asp"-->
  7 </head>
  8 <body><div data-role="page">
  9 
 10   <div data-role="header">
 11     <h1>Update your task</h1>
 12   </div><%
 13     Id = Request.querystring("Id")
 14   %>
 15 <%   Set DATABASE = Server.CreateObject("ADODB.Connection")
 16     DATABASE.Open strConnect
 17 
 18 SQLStr = "SELECT * FROM Tasks WHERE Id = '" &  Id & "' "
 19   Set RSDatabase = DATABASE.Execute(SQLStr)
 20 
 21 
 22  if not RSDatabase.bof AND not RSDatabase.eof then
 23   Id =  RSDatabase("Id")
 24   Name=  RSDatabase("Name")
 25   Email =  RSDatabase("Email")
 26   Tlf =  RSDatabase("tlf")
 27   TaskType =  RSDatabase("TaskType")
 28   Institution =  RSDatabase("Institution")
 29   Location=  RSDatabase("Location")
 30   Priority = RSDatabase("Priority")
 31   Description = RSDatabase("Description")
 32   DateR = RSDatabase("DateR")
 33   DateU = RSDatabase("DateU")
 34   Comments = RSDatabase("Comments")
 35   Status = RSDatabase("Status")
 36CaseID = RSDatabase("CaseID")
 37
 38 Assigned = RSDatabase("Assigned")
 39 
 40   If status = 1 then status_nr = "<td valign=center align=center bgcolor=FF0000><font color=ffffff><b>Status</b><br>Recieved</font></TD>"
 41   If status = 2 then status_nr = "<td valign=center align=center bgcolor=FFFF00><b>Status</b><br>See comments</TD>"
 42   If status = 23 then status_nr = "<td valign=center align=center bgcolor=009933><font color=ffffff><b>Status</b><br><font color=ffffff>Completed</font></TD>"
 43   If status = 24 then status_nr = "<td valign=center align=center bgcolor=FFFFFF><font color=ff0000><b>Status</b><br>Rejected</TD>"
 44 
 45 
 46 
 47   DIM mySQL6, objRS6
 48   mySQL6 = "SELECT User, Name FROM Users WHERE User = '" & assigned & "'"
 49   Set objRS6 = Server.CreateObject("ADODB.Recordset")
 50   objRS6.Open mySQL6, strConnect
 51 
 52   DIM strUser
 53   strUser = objRS6("User")
 54   strName = objRS6("Name")
 55 
 56 
 57 If Assigned <> "" Then
 58 show_assigned = "<br><font color='#FF0000'><b>Task is assigned " & strName & "</br></font>"
 59 End if
 60 
 61 else  ' if not RSDatabase.bof or not RSDatabase then ' run the code
 62    
 63     response.write "No Data"
 64 
 65 end if  'if not RSDatabase.bof or not RSDatabase then ' run the code
 66 %>

Open in new window

0
 

Author Comment

by:micamb
ID: 41770110
Horrific solution...

I have a default user in that table. If I fake the code to look like it's assigned to that user it works.
It requires a little bit of manipulating here and there, but...

If assigned = "" then
assigned_show = "USERINDATABASE"
Else
assigned_show = assigned
End if

Open in new window


It ain't pretty, but it works!
0
 
LVL 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 2000 total points
ID: 41770113
My solution that worked was
'   ### assume recordset named RSDatabase is created ###
IF NOT RSDatabase.BOF OR NOT RSDatabase.EOF THEN

         ' ### add code here that uses the recordset RSDatabase

      ELSE

         ' # optionally add some code that lets you know the recordset is not available
 
END IF

Open in new window


Line 52 is the same error and I just showed you how to test if the recordset has data and you just need to run the test for that recordset.

It looks like you have some some nesting issues.  To help identify, please update your code where you are indenting for IF/THEN and looping.  Once you do that, post back your code although doing that may help you solve this next issue you are having.
0
 
LVL 53

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 2000 total points
ID: 41770122
>Horrific solution...

I'm not sure if you meant that for what I provided or your work around.  

What I provided worked and only uncovered another issue.  Try to avoid making workarounds because they are just short term fix's that create long term problems.  

Open your db

     create your recordset
                test if recordset is good
                       start looping
                              run code
                       end loop
                end if
     close your recordset

     open another recordset
                test if recordset is good
                       start looping
                              run code
                       end loop
                end if
     close recordset then close db.  

close db

Open in new window


Keep your logic and code in order and you will have an easier time.
0
 

Author Comment

by:micamb
ID: 41770149
My solution was/is horrific absolutely! Being a complete amateur doesn't help when you are trying to code stuff... I'm really pressed for time, so I'll appoint your solution as the actual solution since mine is more a beating-around-the-bush-kind-of-thing. Thanks for your effort!
0

Featured Post

Industry Leaders: 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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

722 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