Error C2871: "ADODB": The namespace with this name does not exist (error C2871: "ADODB": The namespace with this name does not exist), c2871 namespace

Source: Internet
Author: User

Error C2871: "ADODB": The namespace with this name does not exist (error C2871: "ADODB": The namespace with this name does not exist), c2871 namespace

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

I just added# 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,

//Are changed infrequently

//

// # Import "C: \ Program Files \ Common Files \ System \ ado \ msado15.dll" no_namespace rename ("EOF", "adoEOF ")//// Error

# If! Defined (afx_stdafx_h1_c914c8d4_56eb_44cd_ae77_600c6d941ba21_included _)

# Define afx_stdafx_h1_c914c8d4_56eb_44cd_ae77_600c6d941ba21_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_h1_c914c8d4_56eb_44cd_ae77_600c6d941ba21_included _)

    2 error C2011: 'peypeenum': 'enum' type redefinition Solution

1> ------ generated: Project: iotser, configuration: Debug Win32 ------
1> compiling...
1> iotser. cpp
1> f: \ c ++ pro \ iocptser \ debug \ msado15.tlh (228): error C2011: "LockTypeEnum": "enum" type redefinition
1>      C: \ program files \ microsoft sdks \ windows \ v6.0a \ include \ dbdaoint. h (109): see the "LockTypeEnum" statement.
1> f: \ c ++ pro \ iocptser \ debug \ msado15.tlh (276): error C2011: "DataTypeEnum": "enum" type redefinition
1>      C: \ program files \ microsoft sdks \ windows \ v6.0a \ include \ dbdaoint. h (138): See the DataTypeEnum statement.
1> f: \ c ++ pro \ iocptser \ debug \ msado15.tlh (321): error C2011: "FieldAttributeEnum": "enum" type redefinition
1>      C: \ program files \ microsoft sdks \ windows \ v6.0a \ include \ dbdaoint. h (127): see the "FieldAttributeEnum" Statement
1> f: \ c ++ pro \ iocptser \ debug \ msado15.tlh (343): error C2011: "EditModeEnum": "enum" type redefinition
1>      C: \ program files \ microsoft sdks \ windows \ v6.0a \ include \ dbdaoint. h (83): see the "EditModeEnum" statement.
1> f: \ c ++ pro \ iocptser \ debug \ msado15.tlh (352): error C2011: "RecordStatusEnum": "enum" type redefinition
1>      C: \ program files \ microsoft sdks \ windows \ v6.0a \ include \ dbdaoint. h (341): see the "RecordStatusEnum" Statement
1> f: \ c ++ pro \ iocptser \ debug \ msado15.tlh (616): error C2011: "parameterdireoneonenum": "enum" type redefinition
1>      C: \ program files \ microsoft sdks \ windows \ v6.0a \ include \ dbdaoint. h (326): see the "ParameterDirectionEnum" statement.
1> f: \ c ++ pro \ iocptser. cpp (18): error C2871: "ADODB": The namespace with this name does not exist
1> the generated logs are stored in "file: // f: \ C ++ pro \ iocptser \ Debug \ BuildLog.htm"
1> iocptser-7 errors and 0 warnings
============ Generate: 0 successful, 1 failed, 0 latest, skipped 0 ==========


After searching on csdn, we found the following two solutions 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", "adoparameterdireenuM ")

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.