C++ ADO数据库

 #import "c:\program files\common files\system\ado\msado15.dll"    no_namespace    rename ("EOF", "adoEOF"), rename("BOF","adoBOF") 
问题:   编译后,出现以下错误:  
msado15.tlh(169) : error C2011: 'LockTypeEnum' : 'enum' type redefinition  
msado15.tlh(212) : error C2011: 'DataTypeEnum' : 'enum' type redefinition  
msado15.tlh(256) : error C2011: 'FieldAttributeEnum' : 'enum' type redefinition  
msado15.tlh(277) : error C2011: 'EditModeEnum' : 'enum' type redefinition  
msado15.tlh(285) : error C2011: 'RecordStatusEnum' : 'enum' type redefinition  
msado15.tlh(405) : warning C4146: unary minus operator applied to unsigned type, result still unsigned  
msado15.tlh(527) : error C2011: 'ParameterDirectionEnum' : 'enum' type redefinition   …

原因:

      是因为我们建立MFC DLL 工程时,VC在stdafx.h中包含了如下两个操作数据库的类的头文件
      include <afxdb.h>            // MFC database classes
      include <afxdao.h>          // MFC DAO database

      与ADO库中的类型定义冲突。


解决方法:

1、若没有用到上述两个头文件中的类,则去掉stdafx.h中下面所示的两行代码。  
        #include <afxdb.h>        // MFC database classes  
        #include <afxdao.h>       // MFC DAO database

2、导入库时不去掉命名空间,即不加no_namespace 。导入语句改为
        #import "C:\Program Files\Common Files\System\ADO\msado15.dll"     rename("EOF","adoEOF"), rename("BOF","adoBOF")         
         using namespace ADODB; //在用到ADO类的头文件中添加此语句

3、用rename修改所有重定义的类型名称.
           rename("LockTypeEnum","adoLockTypeEnum")
           rename("DataTypeEnum","adoDataTypeEnum")

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值