編寫類的DLL時,類中用到ADO資料庫,出現類型重定義的問題解決及原因!!

來源:互聯網
上載者:User

錯誤清單:

 >d:\test\autoloadmatrix\personadd\debug\msado15.tlh(228) : error C2011: “LockTypeEnum”: “enum”類型重定義
1>        c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(109) : 參見“LockTypeEnum”的聲明
1>d:\test\autoloadmatrix\personadd\debug\msado15.tlh(276) : error C2011: “DataTypeEnum”: “enum”類型重定義
1>        c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(138) : 參見“DataTypeEnum”的聲明
1>d:\test\autoloadmatrix\personadd\debug\msado15.tlh(321) : error C2011: “FieldAttributeEnum”: “enum”類型重定義
1>        c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(127) : 參見“FieldAttributeEnum”的聲明
1>d:\test\autoloadmatrix\personadd\debug\msado15.tlh(343) : error C2011: “EditModeEnum”: “enum”類型重定義
1>        c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(83) : 參見“EditModeEnum”的聲明
1>d:\test\autoloadmatrix\personadd\debug\msado15.tlh(352) : error C2011: “RecordStatusEnum”: “enum”類型重定義
1>        c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(341) : 參見“RecordStatusEnum”的聲明
1>d:\test\autoloadmatrix\personadd\debug\msado15.tlh(616) : error C2011: “ParameterDirectionEnum”: “enum”類型重定義
1>        c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(326) : 參見“ParameterDirectionEnum”的聲明
1>d:\program files\opencv2.0\vc2008\include\opencv\cvcompat.h(803) : warning C4819: 該檔案包含不能在當前字碼頁(936)中表示的字元。請將該檔案儲存為 Unicode 格式以防止資料丟失
1>d:\test\autoloadmatrix\personadd\add.cpp(131) : error C2065: “adLockReadOnly”: 未聲明的標識符
1>d:\test\autoloadmatrix\personadd\add.cpp(191) : error C2065: “adLockOptimistic”: 未聲明的標識符
1>d:\test\autoloadmatrix\personadd\add.cpp(244) : error C2065: “adLockOptimistic”: 未聲明的標識符
1>d:\test\autoloadmatrix\personadd\add.cpp(289) : error C2065: “adLockOptimistic”: 未聲明的標識符
1>d:\test\autoloadmatrix\personadd\add.cpp(499) : error C2065: “adLockReadOnly”: 未聲明的標識符
1>d:\test\autoloadmatrix\personadd\add.cpp(710) : error C2065: “adLockOptimistic”: 未聲明的標識符
1>d:\test\autoloadmatrix\personadd\add.cpp(728) : error C2065: “adLockOptimistic”: 未聲明的標識符
1>PASSWD.cpp
1>d:\test\autoloadmatrix\personadd\debug\msado15.tlh(228) : error C2011: “LockTypeEnum”: “enum”類型重定義
1>        c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(109) : 參見“LockTypeEnum”的聲明
1>d:\test\autoloadmatrix\personadd\debug\msado15.tlh(276) : error C2011: “DataTypeEnum”: “enum”類型重定義
1>        c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(138) : 參見“DataTypeEnum”的聲明
1>d:\test\autoloadmatrix\personadd\debug\msado15.tlh(321) : error C2011: “FieldAttributeEnum”: “enum”類型重定義
1>        c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(127) : 參見“FieldAttributeEnum”的聲明
1>d:\test\autoloadmatrix\personadd\debug\msado15.tlh(343) : error C2011: “EditModeEnum”: “enum”類型重定義
1>        c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(83) : 參見“EditModeEnum”的聲明
1>d:\test\autoloadmatrix\personadd\debug\msado15.tlh(352) : error C2011: “RecordStatusEnum”: “enum”類型重定義
1>        c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(341) : 參見“RecordStatusEnum”的聲明
1>d:\test\autoloadmatrix\personadd\debug\msado15.tlh(616) : error C2011: “ParameterDirectionEnum”: “enum”類型重定義
1>        c:\program files\microsoft sdks\windows\v6.0a\include\dbdaoint.h(326) : 參見“ParameterDirectionEnum”的聲明
1>d:\test\autoloadmatrix\personadd\passwd.cpp(120) : error C2065: “adLockOptimistic”: 未聲明的標識符
1>Crypt.cpp
1>正在產生代碼...
1>組建記錄檔儲存在“file://d:\test\AutoLoadMatrix\PersonAdd\Debug\BuildLog.htm”
1>PersonAdd - 20 個錯誤,1 個警告

 

原因分析:

    1、在標頭檔中:

    #import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF", "EndOfFile")

    2、在“stdafx.h ”檔案中,

#ifndef _AFX_NO_DB_SUPPORT
#include <afxdb.h>                      // MFC ODBC 資料庫類
#endif // _AFX_NO_DB_SUPPORT

#ifndef _AFX_NO_DAO_SUPPORT
#include <afxdao.h>                     // MFC DAO 資料庫類
#endif // _AFX_NO_DAO_SUPPORT

1與2進行了相同的操作,所以會出現重定義的錯誤!!

解決方案:

     1與2隻能留一個!

     將以下代碼注釋:

#ifndef _AFX_NO_DB_SUPPORT
#include <afxdb.h>                      // MFC ODBC 資料庫類
#endif // _AFX_NO_DB_SUPPORT

#ifndef _AFX_NO_DAO_SUPPORT
#include <afxdao.h>                     // MFC DAO 資料庫類
#endif // _AFX_NO_DAO_SUPPORT

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.