Max no of CRecordsets?
3 messages in this thread
Dan:
This is a question which interests me as well. Though I haven't hit the problem
yet, if it is actually as Norbert describes, I will hit it soon.
Unfortunately, there is no article Q115516 in either the MS Developer
Knowledgebase (MDKB) or the MS Knowledgebase (MSKB). What gives?
Rondal Ellifritt
Well, I have found a solution for my problem (it was in the KBase. Search for
CRecordset).
There is a bug in the CRecordset destructor. Each CRecordset::Open call creates
a temporary file in the TEMP directory (at least the access odbc driver does).
If you delete your CRecordset derived object before explicitly closing it, the
connection to the data base does not close correctly, and the temp file remains
open. If you create and delete CRecordset objects dynamically, this very soon
causes a 'number of files overflow', giving very strange errors.
Solution: Derive a class CMyRecordset and overload the destructor:
class CMyRecordset : public CRecordset
{
public:
virtual ~CMyRecordset() { Close(); }
};
This will close and remove the temp file. And plan one file handle per open
CRecordset object.
Norbert
Thanks, Norbert. Now that you explain it, I'm not sure I will run into this
problem, but it's nice to know the solution in case I do.