Solved

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

Posted on 2007-03-30
2
256 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

707 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

13 Experts available now in Live!

Get 1:1 Help Now