PRB: Couldn't Find Object on Recordset for Predefined QueryLast reviewed: July 18, 1997Article ID: Q131401 |
1.50 1.51 1.52 1.52a
WINDOWS
kbusage kberrmsg kbprb
The information in this article applies to:
SYMPTOMSWhen using the MFC database classes and trying to open a snapshot recordset for a Microsoft Access version 2.0 predefined query, a database exception is thrown, and the following error message is seen in the output window:
Couldn't find object '|'. State:S0002[Microsoft][ODBC Microsoft Access 2.0 Driver] CAUSEThe MFC encylopedia article "Recordset: Declaring a Class for a Predefined Query" discusses how to make a CRecordset class that opens a predefined query. It mentions that the database classes don't support updating predefined queries. It doesn't explicitly mention that you have to open your recordset as read-only, but you should. If a recordset is opened as a snapshot without specifying a read-only recordset, the database classes append the string "FOR UPDATE OF" to the end of the SQL statement that defines a query. This added phrase is invalid in a SQL statement that uses the CALL keyword to execute a predefined query.
RESOLUTIONTo avoid this problem, open the recordset as read-only by specifying CRecordset::readOnly as the third parameter to the CRecordset::Open() function. Your open function should look something like this:
myRecordset.Open(CRecordset::snapshot, // open as snapshot "{call MyQuery}", // call predefined query CRecordset::readOnly); // must be read-only! STATUSThis behavior is by design.
REFERENCESMFC Encyclopedia Article, "Recordset: Declaring a Class for a Predefined Query.
|
Additional reference words: 2.50 2.51 2.52 2.52a
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |