MFC 4.0 -> 4.2 AddNew/Update/MoveFirst problem 
Author Message
 MFC 4.0 -> 4.2 AddNew/Update/MoveFirst problem

Hi;

I have an MFC 4.0 app that does the following:

Goes against Access 95 and uses MFC w/ CDatabase and CRecordset.

<Opens CDatabase w/o cursor lib>
<Opens CRecordset with dynaset>
...

CRecordSet.Requery (); // This ALWAYS returns no data.
CRecordSet.AddNew ();
<Fill data w/o filling primary key - it's an autoinc>
CRecordSet.Update ();
CRecordSet.MoveFirst ();

The MoveFirst work fine in 4.0.  This is the way I get the value of the
primary key
which is an autoinc field.  The 4.0 app works on two different machines
- 1 with 4.0 and the other with 4.2.
The app does NOT work on 4.2.  I get an ASSERT in dlgcore on the move
first.

Any ideas on how to either:
A) Get the sequence to work using MFC 4.2.
B) Get the primary key value w/o moving to the record that was just
added.

Thanks in advance
Todd



Fri, 20 Aug 1999 03:00:00 GMT  
 MFC 4.0 -> 4.2 AddNew/Update/MoveFirst problem

  Why can't you just Requery the recordset after adding the record?

The query I am using returns nothing.  If I run a query that is all
records, do add new/update then requery,
it should put the newly added record at the end so I can do a move last
and get the key.  I was worried about
the speed.  Will requery only go after the new record(s) added since the
last query?

Thanks
Todd



Fri, 20 Aug 1999 03:00:00 GMT  
 MFC 4.0 -> 4.2 AddNew/Update/MoveFirst problem

Todd,

I had the same problem and someone gave me this solution. I have not verified
that it works but you may want to give it a go:

the MoveLast exception after inserting a new record is new in mfc 4.2.
For mfc 4.2b I found  a workaround. After AddNew() and Update() you must
include the following rows before the MoveLast() row:
m_bEOF =3D FALSE;
m_bBOF =3D FALSE;

Hope this helps,

David Bosley



Quote:

>  Why can't you just Requery the recordset after adding the record?

>The query I am using returns nothing.  If I run a query that is all
>records, do add new/update then requery,
>it should put the newly added record at the end so I can do a move last
>and get the key.  I was worried about
>the speed.  Will requery only go after the new record(s) added since the
>last query?

>Thanks
>Todd



Sun, 22 Aug 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VC 4.0 > 4.2

2. MFC 4.2 and NT 4.0

3. ACCESS update via MFC ( VC++ 4.2) classes using ODBC

4. MSVC 4.2 Problems (MFC/non MFC)

5. 4.2 -> 5.0 conversion problems

6. VC++ 4.2=>VC++6.0 Help problems

7. 4.2 -> 5.0 conversion problems

8. Problem with DOA Update and AddNew

9. Problems debugging MFC under VC 4.2 with separate VC 5.0 installation present

10. Problems relating the Win32 Development with VC++ 4.2 and MFC

11. MFC problem for VC++ 4.2

12. Toolbars MFC 4.2 dock problems?

 

 
Powered by phpBB® Forum Software