• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 387
  • Last Modified:

MFC with ADO

I am trying to build a database app using ADO and at the same time using MFC classes like CString to do a lot of the work. The compiler does not like this and gives an error saying that MFC apps cannot include windows.h.
I have tried everything to get rid of this error but it does not compile.
If anybody has any experience in using ADO with MFC please share this information with me..

1 Solution
You'll get this problem if you #import ado.dll before you #include the MFC headers.  Just move the #import to the bottom of StdAfx.h and you should be okay:

   #include <afxwin.h>         // MFC core and standard components
   #include <afxext.h>         // MFC extensions
   #include <afxdisp.h>        // MFC Automation classes
   #include <afxdtctl.h>            // MFC support for Internet Explorer 4 Common Controls
   #include <afxcmn.h>                  // MFC support for Windows Common Controls

   #import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "adoEOF")

-- Zizzer
tjainAuthor Commented:
Thanks it works..
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now