Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 28th, 2014, 09:11 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default Why use BOF and EOF

Hello - I am wanting opinions on why I see this in some places:

Code:
if objRS.EOF AND objRS.BOF then
    no records found do nothing
else
    records found so do stuff
end if
For many many years I have always only ever found the need for this:

Code:
if objRS.EOF  then
    no records found do nothing
else
    records found so do stuff
end if
Is there really any need for the BOF? or is this completely unnecessary like I believe?

TYIA
__________________
Wind is your friend
Matt
 
Old August 3rd, 2014, 01:17 AM
Friend of Wrox
 
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts
Default

because just testing EOF does not tell you that there were no records in the record set, it just tells that you have reached the end of the record set. if you open a record set that contained no records then both would set.

for the 1st if block testing both does nothing for you as you do "nothing" with the fact you have no records.

for second if block the only thing you have determined is that you have reached the end of the record set.

take a look at this

Code:
if objRS.EOF AND objRS.BOF then
   ''image this logger sends email when error condition arise
   Logger.Error("Error: No records found where we expected records")
else
 ''handle my record 
end if
VS
Code:
if objRS.EOF  then
   ''sending an email here for an empty record set could be a false positive
   '' because just testing EOF means I have reached the end of a record set
   '' not the record set was empty
   Logger.Error("Error: No records found where we expected records")
else
   ''handle my record
end if

Last edited by mmorgan30; August 3rd, 2014 at 01:20 AM..
 
Old August 3rd, 2014, 07:44 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Hi mmorgan30

Thank you for your time and comments however I have to 100% disagree with all of your comments except one. Yes EOF means end of file and yes BOF is before.......

But im sorry, just testing for EOF does satisfy both effectively when asking if a query returned any results. Just saying IF NOT EOF then do stuff... ELSE dont do stuff... does work every time for me, and has for many mnay years, it continues to work every day as I am still in the classic ASP world full time (believe it or not). Not once has a query ever given me what you call a 'false positive'

Just to clarify my original question was why use BOF and EOF I have only ever used EOF by its self and never hit issues. Is BOF a waste of time and typing?
__________________
Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Either BOF or EOF is True, Akram Access ASP 2 March 1st, 2011 09:07 AM
"Either BOF or EOF is True" need help! murshed Classic ASP Databases 4 March 18th, 2008 03:43 PM
Re-try - BOF-EOF error JpaulH Access VBA 2 May 4th, 2006 02:16 PM
Access to Excel - BOF or EOF error JpaulH Access VBA 1 May 3rd, 2006 04:30 PM
RecordCount Query returns EOF and BOF jigs_bhavsar Pro VB Databases 3 November 11th, 2004 09:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.