[horrible mess of code snipped]
I think the answer is exactly as Chris described. You need to read the
column of data into some data structure, and return the entire column in one
go to the calling program. Then the calling program can loop though all the
data in whatever way it likes.
The best data structure would be a std::vector<int> (I think you're dealing
with integer data). There's an MFC alternative to this but I forget what its
called, ask in an MFC newsgroup. You could even use an array or a pointer to
dynamically allocated memory.
Nothing in the code you posted (apart from the OLE stuff) cannot be done
with standard C++, so there is no good reason to use CString (prefer
std::string), _open (prefer ifstream). Even OLEVariant can possibly be
replaced with boost::any (see
www.boost.org). Don't use non standard code
unnecessarily, apart from any other consideration (such as portability) it
means that your code is off topic in a group that discusses standard C++
like this one.
John