Solved

CRecordset, EOF and BOF differences on Win2k vs. XP?

Posted on 2007-03-30
2
258 Views
Last Modified: 2013-11-20
I am suddenly having a problem. I am using V++ 6.0.  I execute a query that I am absolutely certain will return 1 record.  (in this case that is, there are times it may not return anything, so I have to check for empty, but the problem is when it does)

I check if it's got any data using the following, which is the way I've always done it:

            if (!recset->IsEOF() && !recset->IsBOF())

This has been working in debug and release on Win2k.. Suddenly I run it on XP and that line continued to fail, as if EOF and BOF were both true, as if there were no data returned.. I added traces and message box's and such using GetRecordCount, and in fact GetRecordCount() returned 1 while at the same time the above IF statement failed as if there were no records.

What's going on here?  I can replace that with:

             if (recset->GetRecordCount() > 0)

and be up and running again on both platforms, but I'm confused as to why it suddenly does not work? This is just in this one scenario as well, I use similar statements to check for empty record sets elsewhere in the app, and they continue to perform as expected.

Any thoughts??

Thanks
0
Comment
Question by:PMH4514
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 125 total points
ID: 18825233
I use the following logic:
            if (! (recset->IsEOF() && recset->IsBOF()) )
0
 

Author Comment

by:PMH4514
ID: 18825853
well strangely enough using your version worked.

(strange in that I see no reason why mine didn't?)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

911 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now