PRB: "Invalid Cursor State" Error After Changing DirectoryLast reviewed: July 3, 1997Article ID: Q156930 |
The information in this article applies to:
SYMPTOMSWhen 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 CAUSEThe 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.
RESOLUTIONDo 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(); STATUSThis behavior is by design. |
Keywords : kbprg MfcDatabase
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |