473,387 Members | 3,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Stopping EOF(End Of File) from happening?

6
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?

Expand|Select|Wrap|Line Numbers
  1.  
  2. set rs = server.createobject("adodb.recordset")
  3.  
  4. dim location 
  5. location = Session("location")
  6.  
  7. strSQL = "SELECT * " _
  8.         & "FROM db_accessadmin.callbacks " _
  9.         & "WHERE location ='"& location &"' AND "_
  10.         & "status ='Open' OR " _
  11.         & "status ='WIP' " _
  12.         & "ORDER BY ID desc;"
  13.  
  14. rs.Open strSQL, oConn, adOpenStatic
  15.  
  16. Dim intcount1
  17. intcount1 = 0
  18.  
  19. If Not rs.EOF Then
  20.  
  21. rs.MoveFirst
  22.  
  23. Do while Not rs.EOF
  24.  
  25. StartTime = rs("date")
  26. diff1 = (DateDiff("h",StartTime,EndTime))
  27.  
  28. intcount1 = intcount1 + 1
  29. dim count1
  30. count1 = intcount1
  31.  
  32.     response.write "<tr><td><font face='Arial' color='#111111' size='2'>" & rs("admin") &  "</td></font>"
  33.     response.write "<td><font face='Arial' size='2'>" & rs("ticket") &  "</td></font>"
  34.     response.write "<td><font face='Arial' size='2'>" & rs("helpdesk") &  "</td></font>"
  35.     response.write "<td><font face='Arial' size='2'>" & rs("division") &  "</td></font>"
  36.     response.write "<td><center><font face='Arial' size='2'>" & diff1 & "</td></font></center>"
  37.     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>"
  38.  
  39. rs.moveNext
  40. loop
  41.  
  42. End If
  43.  
  44. response.write "<font face='Arial' color='#344C7C' size='1'><b>All Other Callbacks =&nbsp;" & count1 & "</b></font>"
  45.  
  46. rs.close
  47. set rs=nothing
  48.  
  49. oConn.close
  50. set oConn=nothing
  51.  
Any assistance would be greatly appreciated!
Mar 28 '08 #1
2 1363
DrBunchman
979 Expert 512MB
Hi Pauley,

You shouldn't need to use
Expand|Select|Wrap|Line Numbers
  1.  If Not rs.EOF 
  2.  
  3. rs.MoveFirst
  4.  
  5. ...code...
  6.  
  7. End If
  8.  
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
Mar 31 '08 #2
jhardman
3,406 Expert 2GB
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
Apr 1 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Karlo Basic | last post by:
Hi! I hope I'm asking the right question in the right group. I have a problem with a piece of C++ code that runs well under Linux (gcc 2.96) but doesn't run as expected in Windows (Borland C++...
2
by: Sacha Korell | last post by:
How would I check for an end of file when parsing a text file using the StreamReader object? I would like to do something like this: '******************************** Dim objStreamReader As...
22
by: David Warner | last post by:
Greetings! I am working on a C app that needs to read print files generated by lp that contain HP LaserJet PCL codes. If the PCL contains binary data to define a bit map to be printed on the...
0
by: carmen413 via VBMonster.com | last post by:
Dear All, my text file like following, a1, b1, c1, d1, e1 a2, b2, c2, d2, e2 a3, b3, c3, d3, e3 a4, b4, c4, d4, e4 .................
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.