checking for EOF...

Results 1 to 3 of 3

Thread: checking for EOF...

  1. #1
    Join Date
    Dec 1969

    Default checking for EOF...

    When is this necessary? For example, here&#039;s what I&#039;ve been doing...<BR><BR>Dim strConn, rs, strSQL<BR>Dim strShowErrorsCollection<BR>Dim intErrNumber, strErrDescription, strErrSource<BR>on error resume next<BR>strConn = application("strConnWebdb")<BR>Set rs = Server.CreateObject("ADODB.Recordset")<BR>strSQL = "SELECT Link_URL,Blurb_Text,Sort_Order,Posted_Date,Announc eCat.Cat_Name " & _<BR> "FROM Announcements JOIN AnnounceCat " & _<BR> "ON (Announcements.AnnounceCatID = AnnounceCat.AnnounceCatID)" & _<BR> "WHERE Link_Status = &#039;live&#039;" & _<BR> "ORDER BY Sort_Order DESC, Posted_Date DESC"<BR> strSQL, strConn, adOpenForwardOnly, adLockReadOnly<BR>strShowErrorsCollection = CheckErrorsCollection(rs.ActiveConnection) &#039;check the errors collection and store returned error message<BR>If strShowErrorsCollection = "No Errors" Then<BR> If rs.EOF then &#039;if no record found for this page&#039;s section<BR> &#039;raise custom error<BR> intErrNumber = vbObjectError + 1003<BR> strErrDescription = "No Announcements returned"<BR> strErrSource = "ShowAnnoucements procedure in $common.asp"<BR> err.Raise intErrNumber, strErrSource, strErrDescription<BR> else<BR> arrAnnouncements = rs.GetRows()<BR> End if <BR>End if<BR>rs.Close<BR>set rs = nothing<BR>MyErrorHandling strShowErrorsCollection,"Error when getting announcements from db",null <BR>On Error Goto 0 <BR><BR>Is it necessary for me to check for EOF when I get my recordset, and then raise a custom error? If the record is not there, then wouldn&#039;t an ADO error be raised?

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default It is necessary

    everytime you are trying to access data from the db. Even if you FEEL there will always be data, might as well do it, it will be safer.<BR><BR>now if you have some querys like select count(..)... then you need not care caue that will ALWAYS return a record, the count may be 0 but there WILL be a record.<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default EOF is *NEVER* an error...

    Why didn&#039;t you just try it???<BR><BR>Do you ever see any error being raised from the EOF?<BR><BR>Now...*IF* you get an EOF and *THEN* you do<BR> arrAnnouncements = rs.GetRows()<BR>you will get an error, yes.<BR><BR>But the EOF, per se, raises no error.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts