国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > php开源 > php教程 > error C2871: “ADODB”: 具有该名称的命名空间不存在(error C2871: “ADODB”: 具有该名称的命名空间不存在)

error C2871: “ADODB”: 具有该名称的命名空间不存在(error C2871: “ADODB”: 具有该名称的命名空间不存在)

来源:程序员人生   发布时间:2015-04-28 08:27:58 阅读次数:6208次

1.WINDOWS.H already included. MFC apps must not #include <windows.h>

I just added the #import "C:Program FilesCommon FilesSystemadomsado15.dll" no_namespace rename("EOF","ADOEOF")

in the <StdAfx.h> file. When the import sentence was add in the head of file,the error occured. But when I moved it to the tail of the file,Everything was OK. I don't know why.

 

// stdafx.h : include file for standard system include files,

//  or project specific include files that are used frequently, but

//      are changed infrequently

//

//#import "C:Program FilesCommon FilesSystemadomsado15.dll" no_namespace rename("EOF","adoEOF")   ////error

#if !defined(AFX_STDAFX_H__C914C8D4_56EB_44CD_AE77_600C6D941BA2__INCLUDED_)

#define AFX_STDAFX_H__C914C8D4_56EB_44CD_AE77_600C6D941BA2__INCLUDED_

 

#if _MSC_VER > 1000

#pragma once

#endif // _MSC_VER > 1000

 

#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers

 

#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

#ifndef _AFX_NO_AFXCMN_SUPPORT

#include <afxcmn.h> // MFC support for Windows Common Controls

#endif // _AFX_NO_AFXCMN_SUPPORT

#import "C:Program FilesCommon FilesSystemadomsado15.dll" no_namespace rename("EOF","ADOEOF") ////is OK

 

//{{AFX_INSERT_LOCATION}}

// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

 

#endif // !defined(AFX_STDAFX_H__C914C8D4_56EB_44CD_AE77_600C6D941BA2__INCLUDED_)

 
 
2error C2011: 'DataTypeEnum' : 'enum' type redefinition解决方法
2009-06⑵6 17:36

1>------ 已启动生成: 项目: iotser, 配置: Debug Win32 ------
1>正在编译...
1>iotser.cpp
1>f:c++ proiocptserdebugmsado15.tlh(228) : error C2011: “LockTypeEnum”: “enum”类型重定义
1>        c:program filesmicrosoft sdkswindowsv6.0aincludedbdaoint.h(109) : 参见“LockTypeEnum”的声明
1>f:c++ proiocptserdebugmsado15.tlh(276) : error C2011: “DataTypeEnum”: “enum”类型重定义
1>        c:program filesmicrosoft sdkswindowsv6.0aincludedbdaoint.h(138) : 参见“DataTypeEnum”的声明
1>f:c++ proiocptserdebugmsado15.tlh(321) : error C2011: “FieldAttributeEnum”: “enum”类型重定义
1>        c:program filesmicrosoft sdkswindowsv6.0aincludedbdaoint.h(127) : 参见“FieldAttributeEnum”的声明
1>f:c++ proiocptserdebugmsado15.tlh(343) : error C2011: “EditModeEnum”: “enum”类型重定义
1>        c:program filesmicrosoft sdkswindowsv6.0aincludedbdaoint.h(83) : 参见“EditModeEnum”的声明
1>f:c++ proiocptserdebugmsado15.tlh(352) : error C2011: “RecordStatusEnum”: “enum”类型重定义
1>        c:program filesmicrosoft sdkswindowsv6.0aincludedbdaoint.h(341) : 参见“RecordStatusEnum”的声明
1>f:c++ proiocptserdebugmsado15.tlh(616) : error C2011: “ParameterDirectionEnum”: “enum”类型重定义
1>        c:program filesmicrosoft sdkswindowsv6.0aincludedbdaoint.h(326) : 参见“ParameterDirectionEnum”的声明
1>f:c++ proiocptseriocptser.cpp(18) : error C2871: “ADODB”: 具有该名称的命名空间不存在
1>生成日志保存在“file://f:C++ proiocptserDebugBuildLog.htm”
1>iocptser - 7 个毛病,0 个正告
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========


后来经过在csdn上的搜索发现有下面两种办法来解决这个问题

1)

#pragma warning(disable:4146)
#import "C:Program FilesCommon FilesSystemADOmsado15.dll" named_guids rename("EOF","adoEOF"), rename("BOF","adoBOF")
#pragma warning(default:4146)
using namespace ADODB;

2)

#pragma warning(disable:4146)
#import "C:Program FilesCommon FilesSystemadomsado15.dll"
no_namespace
rename("EOF","adoEOF") rename("DataTypeEnum","adoDataTypeEnum")
rename("FieldAttributeEnum", "adoFielAttributeEnum") rename("EditModeEnum", "adoEditModeEnum")
rename("LockTypeEnum", "adoLockTypeEnum") rename("RecordStatusEnum", "adoRecordStatusEnum")
rename("ParameterDirectionEnum", "adoParameterDirectionEnum")

生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------
分享到:
------分隔线----------------------------
关闭
程序员人生