Error C2871: "ADODB": namespace with this name does not exist (Error C2871: "ADODB": namespace with this name does not exist)

Source: Internet
Author: User

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 is add in the head of file,the error occured. If I moved it to the tail of the file,everything is OK. I don ' t know why.

Stdafx.h:include file for standard system include files,

or project specific include files that is used frequently, but

is 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 + + would 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 workaround2009-06-26 17:36

1>------Started Build: Project: Iotser, configuration: Debug Win32------
1> is compiling ...
1>iotser.cpp
1>f:\c++ PRO\IOCPTSER\DEBUG\MSADO15.TLH (228): Error C2011: "LockTypeEnum": "Enum" type redefined
1>C:\Program Files\Microsoft Sdks\windows\v6.0a\include\dbdaoint.h (109): See Declaration of "LockTypeEnum"
1>f:\c++ PRO\IOCPTSER\DEBUG\MSADO15.TLH (276): Error C2011: "DataTypeEnum": "Enum" type redefined
1> C:\Program Files\Microsoft Sdks\windows\v6.0a\include\dbdaoint.h (138): See Declaration of "DataTypeEnum"
1>f:\c++ PRO\IOCPTSER\DEBUG\MSADO15.TLH (321): Error C2011: "FieldAttributeEnum": "Enum" type redefined
1>C:\Program Files\Microsoft Sdks\windows\v6.0a\include\dbdaoint.h (127): See Declaration of "FieldAttributeEnum"
1>f:\c++ PRO\IOCPTSER\DEBUG\MSADO15.TLH (343): Error C2011: "EditModeEnum": "Enum" type redefined
1> C:\Program Files\Microsoft Sdks\windows\v6.0a\include\dbdaoint.h (83): See Declaration of "EditModeEnum"
1>f:\c++ PRO\IOCPTSER\DEBUG\MSADO15.TLH (352): Error C2011: "RecordStatusEnum": "Enum" type redefined
1>C:\Program Files\Microsoft Sdks\windows\v6.0a\include\dbdaoint.h (341): See Declaration of "RecordStatusEnum"
1>f:\c++ PRO\IOCPTSER\DEBUG\MSADO15.TLH (616): Error C2011: "ParameterDirectionEnum": "Enum" type redefined
1> C:\Program Files\Microsoft Sdks\windows\v6.0a\include\dbdaoint.h (326): See Declaration of "ParameterDirectionEnum"
1>f:\c++ pro\iocptser\iocptser.cpp: Error C2871: "ADODB": namespace with this name does not exist
1> build log saved in "File://f:\c++ pro\iocptser\debug\buildlog.htm"
1>iocptser-7 a bug, 0 warnings
========== Generation: Success 0, failure 1, latest 0, skip 0 ==========


Later, the search on csdn found that there are two ways to solve this problem.

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": namespace with this name does not exist (Error C2871: "ADODB": namespace with this name does not exist)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.