0

I have an old MFC application I've recently updated to include code that uses CDatabase to access an old MDB.

This works, but when an internal error occurs, I get an assertion in dbcore.cpp that it could not load the error string resource.

After some research, I added the following line to my application's RC file.

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#ifndef APSTUDIO_INVOKED
#include "targetver.h"
#endif
#include "afxres.h"
#include "afxdb.rc"  // <<======= I ADDED THIS LINE HERE!!!

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

This solved the problem. I now got a meaningful message for internal errors. However, now if I try to save my resource file using the resource editor, I get an error.

enter image description here

How can I get meaningful internal database messages and still be able to save changes to my resource file?

Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466
  • Did you try adding moving it to after targetver.h instead so it is in the #ifndef APPSTUDIO_INVOKED block? Or tried moving it to your .rc2 file? (Generally, MFC projects have a YourProject.rc2 file. (YourProject is just an alias for whatever your project name is.) – Joseph Willcoxson Dec 19 '16 at 05:28
  • @JoeWillcoxson: Moving it to the RC2 file seems to work. Thanks. – Jonathan Wood Dec 19 '16 at 17:35

1 Answers1

0

Per Joe Willcoxson's comment, moving the added line to my RC2 file solved the issue. I now have the necessary database resources, and I'm still able to edit and save resources in the resource editor.

Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466