PRB: Couldn't Find Object on Recordset for Predefined Query

Last reviewed: July 18, 1997
Article ID: Q131401
1.50 1.51 1.52 1.52a WINDOWS kbusage kberrmsg kbprb

The information in this article applies to:

  • The Microsoft Foundation Classes (MFC) included with: Microsoft Visual C++ for Windows, versions 1.50, 1.51, 1.52, 1.52a

SYMPTOMS

When 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]

CAUSE

The 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.

RESOLUTION

To 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!

STATUS

This behavior is by design.

REFERENCES

MFC Encyclopedia Article, "Recordset: Declaring a Class for a Predefined Query.


Additional reference words: 2.50 2.51 2.52 2.52a
KBCategory: kbusage kberrmsg kbprb
KBSubcategory: MfcDatabase
Keywords : kb16bitonly MfcDatabase kberrmsg kbprb kbusage
Technology : kbMfc
Version : 1.50 1.51 1.52 1.52a
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 18, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.