Microsoft KB Archive/140598

= FIX: AppendOnly Snapshot Recordset Update Causes Error =

Article ID: 140598

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 2.0 Professional Edition

 Microsoft Visual C++ 2.1

 Microsoft Visual C++ 2.2 

-

<div class="notice_section">

This article was previously published under Q140598

<div class="symptoms_section">

SYMPTOMS
Opening a recordset as an append-only snapshot with no cursor library support leads to an internal application error (ICE) when Update is called to commit an AddNew. A CDBException is thrown and the following error is displayed in the output window of the debugger (DB tracing enabled):

In Visual C++ 2.x using the Microsoft Access 7.0 driver:

<pre class="fixed_text">  Error: failure updating record. Invalid argument value State:S1009,Native:57,Origin:[Microsoft][ODBC Microsoft Access 7.0 Driver]

This happens when the cursor library is inhibited from loading by passing FALSE as the last parameter to CDatabase Open prior to opening the recordset or if the cursor library fails to load for any reason.

<div class="cause_section">

CAUSE
A snapshot recordset relies on the cursor library for additions or updates to the database. If the cursor library is not loaded, the recordset becomes read-only and does not allow additions or updates. In this case, the recordset member variable m_bUpdatable is correctly set to FALSE, but due to a bug in MFC, if the recordset is opened appendOnly, m_bAppendable is still set to TRUE. AddNew checks m_bAppendable and continues to process the addition. Eventually, Update is called. Because the cursor library is not present, Update calls CRecordset::ExecuteSetPosUpdate to use SQLSetPos for performing the update. SQLSetPos fails and generates the error message.

If the appendOnly option is not specified for the snapshot, then both m_bUpdatable and m_bAppendable are set properly and the expected behavior occurs:


 * This error message is displayed in the output window when AddNew is called: "Recordset is read-only."
 * A CDBException is thrown.

<div class="resolution_section">

RESOLUTION
Snapshots become read-only if the cursor library is not loaded. To get an updatable and appendable snapshot, make sure the cursor library is properly loaded by the application.

<div class="status_section">

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem was corrected in Visual C++ version 4.0.

Additional query words: 2.00 3.00 2.10 3.10 2.20 3.20

Keywords: kbbug kbdatabase kbfix KB140598

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.