我建立一个MFC动态链接库的工程,在工程中我添加一个对话框,使得此对话框使用ADO与数据库向连接,但是我在stdafx.h文件中引入ADO的dll文件就报下面的错误
stdafx.h加入下面代码#import "c:\program files\common files\system\ado\msado15.dll" \
no_namespace \
rename ("EOF", "adoEOF")  报的错误是:
d:\workspace_lmr\Project\DllDlg\DllDlg\Debug\msado15.tlh(228) : error C2011: 'LockTypeEnum' : 'enum' type redefinition
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\dbdaoint.h(109) : see declaration of 'LockTypeEnum'
d:\workspace_lmr\Project\DllDlg\DllDlg\Debug\msado15.tlh(276) : error C2011: 'DataTypeEnum' : 'enum' type redefinition
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\dbdaoint.h(138) : see declaration of 'DataTypeEnum'
d:\workspace_lmr\Project\DllDlg\DllDlg\Debug\msado15.tlh(321) : error C2011: 'FieldAttributeEnum' : 'enum' type redefinition
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\dbdaoint.h(127) : see declaration of 'FieldAttributeEnum'
d:\workspace_lmr\Project\DllDlg\DllDlg\Debug\msado15.tlh(343) : error C2011: 'EditModeEnum' : 'enum' type redefinition
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\dbdaoint.h(83) : see declaration of 'EditModeEnum'
d:\workspace_lmr\Project\DllDlg\DllDlg\Debug\msado15.tlh(352) : error C2011: 'RecordStatusEnum' : 'enum' type redefinition
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\dbdaoint.h(341) : see declaration of 'RecordStatusEnum'
d:\workspace_lmr\Project\DllDlg\DllDlg\Debug\msado15.tlh(616) : error C2011: 'ParameterDirectionEnum' : 'enum' type redefinition
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\dbdaoint.h(326) : see declaration of 'ParameterDirectionEnum'怎么解决啊?

解决方案 »

  1.   

    #import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename ("EOF", "adoEOF") 
    不要换行
    《ADO开发指南》
      

  2.   

    我试过了,也不行!
    如果我要建立一个MFC application工程里面添加上面的代码就没有问题,但是要建立一个MFC DLL工程,添加上面这句import的语句,就报上面的错误!
    这是怎么回事,怎么解决啊?
      

  3.   

    解决了,是因为在建立一个MFC DLL工程中的stdafx.h文件中
    #ifndef _AFX_NO_DAO_SUPPORT
    #include <afxdao.h> // MFC DAO database classes
    #endif // _AFX_NO_DAO_SUPPORT
    这个月ADO中的一些定义相冲突。
      

  4.   

    _ConnectionPtr 的Open方法有点问题你自己重新修改一下把