Click to See Complete Forum and Search --> : DAO 3.60 SetBookmark() always fails, worked in 3.50


mmagliaro
March 19th, 2007, 05:53 PM
Hello.

I had a simple db application that opened a .mdb database
and added some records to it. This is all using MFC DAO, Visual
C++ 6.0.

The basic steps are:

CDaoDatabase *mDaoDB; // Our DAO database
CDaoTableDef *mStationsTD; // The table
DAODBEngine* m_DBEngine;

mDaoDB = new CDaoDatabase();
mDaoDB->Open("mydb.mdb", // DB name
TRUE, // Want exclusive access
FALSE, // Not read-only
"");

// I omitted the part that actually created the table mStationsTD.

rs = new CDaoRecordset(mDaoDB);
rs->Open(mStationsTD, dbOpenTable, 0);
rs->AddNew(); // Create empty record

// Under 3.60, I have to do this now...!!!!
// rs->Update();

rs->SetBookmark(rs->GetLastModifiedBookmark());

---------------------------------------

The problem is that the SetBookmark throws a 3021 (E_DAO_NoCurrentRecord) exception when I run this under DAO 3.60.
It works perfectly fine under 3.50.

If I put in the rs->Update(), above, that fixes it. The problem there is
that I have to allow all the fields in my table to be unspecified (have NULL values). Because the Update writes the empty/null record (from the AddNew()) into the database with all default values.

I actually have to do an rs->Edit() after the above code, and THEN
put in all my real data, and then do another rs->Update().

Is this normal behavior? What else might I look for that could be my fault?

Thank you.

database