Microsoft KB Archive/164615

From BetaArchive Wiki
Knowledge Base


FIX: New Record Not Inserted to End of Recordset

Article ID: 164615

Article Last Modified on 11/21/2006



APPLIES TO

  • Microsoft Foundation Class Library 4.2, when used with:
    • Microsoft Visual C++ 4.2 Enterprise Edition
    • Microsoft Visual C++ 4.2 Professional Edition
    • Microsoft Visual C++ 5.0 Enterprise Edition
    • Microsoft Visual C++ 5.0 Professional Edition



This article was previously published under Q164615

SYMPTOMS

The Microsoft Foundation Classes (MFC) documentation for CDaoRecordset::AddNew() and the DAO SDK documentation for the AddNew method state:

   "The position of the record depends on the type of Recordset:
    - In a dynaset-type Recordset object, records are inserted at the end
   of the recordset, regardless of any sorting or ordering rules that may
   have been in effect when the recordset was opened."
                

The documentation is incorrect. Beginning with Jet 3.0, this behavior is not guaranteed. The behavior was changed to improve performance as well as concurrency issues.

To demonstrate the change in behavior, delete a record in a recordset of 300+ records and then call AddNew(). Then, traverse the recordset until you see where the record has been added. Typically, this record will be inserted in the 253rd record rather than at the end of the recordset.

STATUS

This problem was corrected in the documentation for Visual C++, version 6.0.

MORE INFORMATION

If the goal is to make the newly added record the current record, you should get the bookmark of the last modified record and move to that bookmark. You can do this with MFC DAO by doing the following:

   rs.SetBookmark(rs.GetLastModifiedBookmark());
                


Additional query words: AddNew MoveLast

Keywords: kbbug kbdatabase kbdocerr kbdocs kbfix kbnoupdate kbvc600fix KB164615