码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2015-04-08 16:31:28      阅读:1041      评论:0      收藏:0      [点我收藏+]

标签:

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")

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

标签:

原文地址:http://blog.csdn.net/ghevinn/article/details/44941359

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!