您的位置:首页 > 其它

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

2015-04-08 15:24 288 查看
1.WINDOWS.H already included. MFC apps must not #include <windows.h>

I just added the #import "C:\Program Files\Common Files\System\ado\msado15.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 Files\Common Files\System\ado\msado15.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 Files\Common Files\System\ado\msado15.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-26 17:36
1>------ 已启动生成: 项目: iotser, 配置: Debug Win32 ------

1>正在编译...

1>iotser.cpp

1>f:\c++ pro\iocptser\debug\msado15.tlh(228) : error C2011: “LockTypeEnum”: “enum”类型重定义

1> c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(109) : 参见“LockTypeEnum”的声明

1>f:\c++ pro\iocptser\debug\msado15.tlh(276) : error C2011: “DataTypeEnum”: “enum”类型重定义

1> c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(138) : 参见“DataTypeEnum”的声明

1>f:\c++ pro\iocptser\debug\msado15.tlh(321) : error C2011: “FieldAttributeEnum”: “enum”类型重定义

1> c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(127) : 参见“FieldAttributeEnum”的声明

1>f:\c++ pro\iocptser\debug\msado15.tlh(343) : error C2011: “EditModeEnum”: “enum”类型重定义

1> c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(83) : 参见“EditModeEnum”的声明

1>f:\c++ pro\iocptser\debug\msado15.tlh(352) : error C2011: “RecordStatusEnum”: “enum”类型重定义

1> c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(341) : 参见“RecordStatusEnum”的声明

1>f:\c++ pro\iocptser\debug\msado15.tlh(616) : error C2011: “ParameterDirectionEnum”: “enum”类型重定义

1> c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(326) : 参见“ParameterDirectionEnum”的声明

1>f:\c++ pro\iocptser\iocptser.cpp(18) : error C2871: “ADODB”: 具有该名称的命名空间不存在

1>生成日志保存在“file://f:\C++ pro\iocptser\Debug\BuildLog.htm”

1>iocptser - 7 个错误,0 个警告

========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

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

1)

#pragma warning(disable:4146)

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

#pragma warning(default:4146)

using namespace ADODB;

2)

#pragma warning(disable:4146)

#import "C:\Program Files\Common Files\System\ado\msado15.dll" \

no_namespace \

rename("EOF","adoEOF") rename("DataTypeEnum","adoDataTypeEnum") \

rename("FieldAttributeEnum", "adoFielAttributeEnum") rename("EditModeEnum", "adoEditModeEnum") \

rename("LockTypeEnum", "adoLockTypeEnum") rename("RecordStatusEnum", "adoRecordStatusEnum") \

rename("ParameterDirectionEnum", "adoParameterDirectionEnum")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐