FIX: "Invalid Cursor State" Error After Changing DirectoryID: Q156930
|
When using a snapshot recordset with the cursor library loaded passing TRUE for the last argument of CDatabase::Open() or using the CDatabase::useCursorLib flag in the OpenEx() call), you may receive the following ODBC error when trying to do any operation on the recordset following a directory change:
State:24000
Invalid Cursor State
The cursor library creates a temporary file that is used for caching results of the recordset. This temporary file, which starts with CTT..., is created in the current working directory. If the current working directory is changed while a recordset is open, the "Invalid Cursor State" error can occur.
Do not change working directories while a recordset is open or do not use
the cursor library. If you must change the current working directory, save
and restore it before performing the next CRecordset operation. Do this by
using the GetCurrentDirectory() and SetCurrentDirectory() Windows API
functions.
CFileDialog will change the working directory. If you do not want
CFileDialog to change the working directory after you close it, you can use
the OFN_NOCHANGEDIR flag. For example:
CFileDialog dlgFile;
dlgFile.m_ofn.Flags|=OFN_NOCHANGEDIR;
dlgFile.DoModal();
This behavior is by design.
This has been fixed in the latest components of MDAC (MDAC 1.5c and above).
Now, the Cursor library is creating the temporary files in the TEMP
directory.
Additional query words:
Keywords : kbprg kbDatabase kbMFC kbODBC kbVC
Version : 2.0 2.1 2.2 4.0 4.1 4.2 5.0
Platform : NT WINDOWS
Issue type : kbprb
Last Reviewed: August 2, 1999