Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Stopping EOF(End Of File) from happening?

Question posted by: Pauley (Newbie) on March 28th, 2008 02:51 PM
Hello again,

I have an asp page that displays a list of records according to what im pulling in from my select statement. As long as there is a record in the database the page works fine but if all records in the database are deleted then the page crashes.

I've used the same code in other pages and have no problem with it but for some reason this page either hits EOF or BOF and the page just doesn't load. I've tried a bunch of different "If" statements and different combinations of the EOF or BOF statements to try and stop it from hitting end of file but it still does.

Is there an easy way to stop this from happening using my code below?

Code: ( text )
  1. set rs = server.createobject("adodb.recordset")
  2.  
  3. dim location
  4. location = Session("location")
  5.  
  6. strSQL = "SELECT * " _
  7.         & "FROM db_accessadmin.callbacks " _
  8.         & "WHERE location ='"& location &"' AND "_
  9.         & "status ='Open' OR " _
  10.         & "status ='WIP' " _
  11.         & "ORDER BY ID desc;"
  12.  
  13. rs.Open strSQL, oConn, adOpenStatic
  14.  
  15. Dim intcount1
  16. intcount1 = 0
  17.  
  18. If Not rs.EOF Then
  19.  
  20. rs.MoveFirst
  21.  
  22. Do while Not rs.EOF
  23.  
  24. StartTime = rs("date")
  25. diff1 = (DateDiff("h",StartTime,EndTime))
  26.  
  27. intcount1 = intcount1 + 1
  28. dim count1
  29. count1 = intcount1
  30.  
  31.     response.write "<tr><td><font face='Arial' color='#111111' size='2'>" & rs("admin") &  "</td></font>"
  32.     response.write "<td><font face='Arial' size='2'>" & rs("ticket") &  "</td></font>"
  33.     response.write "<td><font face='Arial' size='2'>" & rs("helpdesk") &  "</td></font>"
  34.     response.write "<td><font face='Arial' size='2'>" & rs("division") &  "</td></font>"
  35.     response.write "<td><center><font face='Arial' size='2'>" & diff1 & "</td></font></center>"
  36.     response.write "<td><font size='2' face='Arial'><i><b><a href='ADMINUpdateCallback.asp?FID=" & rs("ID") & "&queue=" & diff1 & "'>" & rs("status") & "</a></b></i></font></td></tr>"
  37.  
  38. rs.moveNext
  39. loop
  40.  
  41. End If
  42.  
  43. response.write "<font face='Arial' color='#344C7C' size='1'><b>All Other Callbacks =&nbsp;" & count1 & "</b></font>"
  44.  
  45. rs.close
  46. set rs=nothing
  47.  
  48. oConn.close
  49. set oConn=nothing


Any assistance would be greatly appreciated!
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
DrBunchman's Avatar
DrBunchman
Moderator
555 Posts
March 31st, 2008
09:19 AM
#2

Re: Stopping EOF(End Of File) from happening?
Hi Pauley,

You shouldn't need to use
Code: ( text )
  1. If Not rs.EOF
  2.  
  3. rs.MoveFirst
  4.  
  5. ...code...
  6.  
  7. End If


Do While Not rs.EOF should be sufficient to test for any records before accessing the record set.

What's the error you receive when it crashes due to no data?

Dr B

Reply
jhardman's Avatar
jhardman
Moderator
2,015 Posts
April 1st, 2008
11:06 PM
#3

Re: Stopping EOF(End Of File) from happening?
I agree with Dr. B. "Do until rs.EOF" always works for me. showing what the error is will help diagnose.

If nothing else, check the record count before you start listing.

Jared

Reply
Reply
Not the answer you were looking for? Post your question . . .
169,969 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Top ASP Forum Contributors