VC下使用ADO数据库访问技术时遇到的问题

昨天在编写一个ADO Demo时遇到了一些问题,就简单整理了一下。
1. 在编译了几次之后突然出现了以下错误,搞了好半天才终于发现,原来是文件视图中多了一个DLGCORE.CPP源文件,于是乎就将其删除,重新编译,果然通过。
Compiling resources...
Compiling...
DLGCORE.CPP
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(45) : warning C4273: 'protected: static struct AFX_MSGMAP const CDialog::messageMap' : inconsistent dll linkage.  dllexport assumed.
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(45) : error C2491: 'CDialog::messageMap' : definition of dllimport static data member not allowed
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(52) : error C2065: 'WM_COMMANDHELP' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(53) : error C2065: 'WM_HELPHITTEST' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(58) : error C2065: 'WM_QUERY3DCONTROLS' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(81) : error C2065: '_AfxCompareClassName' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(101) : error C2065: 'IS_COMMAND_ID' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(171) : error C2065: '_AfxCheckDialogTemplate' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(277) : error C2065: 'AfxDeferRegisterClass' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(277) : error C2065: 'AFX_WNDCOMMCTLS_REG' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(278) : error C2065: 'AFX_WNDCOMMCTLSNEW_REG' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(298) : error C2653: 'CDialogTemplate' : is not a class or namespace name
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(299) : error C2660: 'GetFont' : function does not take 3 parameters
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(312) : error C2065: 'CDialogTemplate' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(312) : error C2146: syntax error : missing ';' before identifier 'dlgTemp'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(312) : error C2065: 'dlgTemp' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(313) : error C2228: left of '.SetSystemFont' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(314) : error C2228: left of '.Detach' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(325) : error C2065: 'AfxHookWindowCreate' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(334) : error C2065: 'DELETE_EXCEPTION' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(348) : error C2065: 'AfxUnhookWindowCreate' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(647) : error C2079: 'info' uses undefined struct 'AFX_CMDHANDLERINFO'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(651) : error C2664: 'OnCmdMsg' : cannot convert parameter 4 from 'int *' to 'struct AFX_CMDHANDLERINFO *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(655) : error C2664: 'OnCmdMsg' : cannot convert parameter 4 from 'int *' to 'struct AFX_CMDHANDLERINFO *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(734) : error C2065: 'DLGTEMPLATEEX' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(734) : error C2059: syntax error : ')'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(735) : error C2143: syntax error : missing ';' before '{'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(737) : error C2059: syntax error : ')'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(738) : error C2059: syntax error : ')'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(739) : error C2059: syntax error : ')'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(741) : error C2181: illegal else without matching if
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(778) : error C2065: 'HID_BASE_RESOURCE' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(827) : error C2373: '_AfxCheckDialogTemplate' : redefinition; different type modifiers
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(854) : error C2065: 'pTemplate' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(854) : error C2059: syntax error : ')'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(856) : error C2227: left of '->signature' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(857) : error C2227: left of '->style' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(893) : warning C4273: 'public: static struct CRuntimeClass const CDialog::classCDialog' : inconsistent dll linkage.  dllexport assumed.
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(893) : error C2491: 'CDialog::classCDialog' : definition of dllimport static data member not allowed
Error executing cl.exe.

SCommTest.exe - 37 error(s), 2 warning(s)
通过查找资料,了解到原来这是VC安装目录下的一个源文件,打开后我们可以看到以下注释:
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-1998 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
简单地说,就是MFC中的几个封装函数的实现。至于它怎么会突然出现在工程中,还有待深究。。。。。

2. 刚开始使用
pConn ->Open(_bstr_t)connString, "", "", adConnectUnspecified);
pSet = pConn ->Excute("select * from studentinfo", NULL, adCmdText);
这种方式来查询,结果在后面的移动记录时出现了问题。

原因:这种方式RecordSet的参数CursorType的默认值为forward-only,使得这种方式不支持游标的双向移动,导致只有RecordSet对象的MoveFirst()和MoveNext()可用,而在使用MoveFirst()和MovePrevious()时就会弹出“runtime error”;

随后改变了记录的查询方式,从而解决了这个问题:
pConn ->Open((_bstr_t)connString, "", "", adConnectUnspecified);
pSet -> Open("select * from studentinfo", (_bstr_t)(*IDispatch)pConn), adOpenDynamic, adLockOptimistic, adCmdText);
这次显式地将RecordSet对象的参数CursorType的值改为了adOpenDynamic,使得其支持游标的双向移动。
3. 由于在查找时需要扫描记录,所以要获取记录总数,但是每次获取到的都是-1,所以将光标类型设置为静态,然后重新编译,运行。
但是再次编译时又出现了以下错误,通过排查,发现文件视图中突然增加了一个CMDTARG.CPP文件,有了上次的经验,所以还是将其删除,当然也就顺利地通过了编译、链接。
Compiling...
CMDTARG.CPP
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(51) : error C2027: use of undefined type 'COleDispatchImpl'
        d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(1721) : see declaration of 'COleDispatchImpl'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(51) : error C2227: left of '->Disconnect' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(69) : error C2079: 'mmf' uses undefined union 'MessageMapFunctions'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(70) : error C2228: left of '.pfn' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(76) : error C2027: use of undefined type 'AFX_CMDHANDLERINFO'
        d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(1303) : see declaration of 'AFX_CMDHANDLERINFO'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(76) : error C2227: left of '->pTarget' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(77) : error C2027: use of undefined type 'AFX_CMDHANDLERINFO'
        d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(1303) : see declaration of 'AFX_CMDHANDLERINFO'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(77) : error C2227: left of '->pmf' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(77) : error C2228: left of '.pfn' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(87) : error C2228: left of '.pfn_COMMAND' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(94) : error C2228: left of '.pfn_bCOMMAND' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(101) : error C2228: left of '.pfn_COMMAND_RANGE' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(107) : error C2228: left of '.pfn_COMMAND_EX' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(112) : error C2065: 'AFX_NOTIFY' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(112) : error C2065: 'pNotify' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(112) : error C2059: syntax error : ')'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(114) : error C2227: left of '->pResult' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(115) : error C2227: left of '->pNMHDR' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(116) : error C2228: left of '.pfn_NOTIFY' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(116) : error C2227: left of '->pNMHDR' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(116) : error C2227: left of '->pResult' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(121) : error C2059: syntax error : ')'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(123) : error C2227: left of '->pResult' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(124) : error C2227: left of '->pNMHDR' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(125) : error C2228: left of '.pfn_bNOTIFY' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(125) : error C2227: left of '->pNMHDR' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(125) : error C2227: left of '->pResult' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(130) : error C2059: syntax error : ')'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(132) : error C2227: left of '->pResult' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(133) : error C2227: left of '->pNMHDR' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(134) : error C2228: left of '.pfn_NOTIFY_RANGE' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(134) : error C2227: left of '->pNMHDR' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(135) : error C2227: left of '->pResult' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(140) : error C2059: syntax error : ')'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(142) : error C2227: left of '->pResult' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(143) : error C2227: left of '->pNMHDR' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(144) : error C2228: left of '.pfn_NOTIFY_EX' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(144) : error C2227: left of '->pNMHDR' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(145) : error C2227: left of '->pResult' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(156) : error C2228: left of '.pfn_UPDATE_COMMAND_UI' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(170) : error C2228: left of '.pfn_UPDATE_COMMAND_UI_RANGE' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(178) : error C2228: left of '.pfn_OTHER' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(181) : error C2228: left of '.pfn_OTHER_EX' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(226) : error C2027: use of undefined type 'COleCmdUI'
        d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(1461) : see declaration of 'COleCmdUI'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(226) : error C2227: left of '->m_pguidCmdGroup' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(243) : error C2027: use of undefined type 'COleCmdUI'
        d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(1461) : see declaration of 'COleCmdUI'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(243) : error C2227: left of '->m_nID' must point to class/struct/union
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(279) : error C2065: 'AfxFindMessageEntry' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(279) : error C2440: '=' : cannot convert from 'int' to 'const struct AFX_MSGMAP_ENTRY *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(364) : warning C4273: 'protected: static struct AFX_MSGMAP const CCmdTarget::messageMap' : inconsistent dll linkage.  dllexport assumed.
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(364) : error C2491: 'CCmdTarget::messageMap' : definition of dllimport static data member not allowed
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(399) : warning C4273: 'protected: static struct AFX_DISPMAP const CCmdTarget::dispatchMap' : inconsistent dll linkage.  dllexport assumed.
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(399) : error C2491: 'CCmdTarget::dispatchMap' : definition of dllimport static data member not allowed
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(439) : warning C4273: 'protected: static struct AFX_EVENTSINKMAP const CCmdTarget::eventsinkMap' : inconsistent dll linkage.  dllexport assumed.
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(439) : error C2491: 'CCmdTarget::eventsinkMap' : definition of dllimport static data member not allowed
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(488) : warning C4273: 'protected: static struct AFX_INTERFACEMAP const CCmdTarget::interfaceMap' : inconsistent dll linkage.  dllexport assumed.
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(488) : error C2491: 'CCmdTarget::interfaceMap' : definition of dllimport static data member not allowed
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(509) : error C2065: 'AfxLockGlobals' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(509) : error C2065: 'CRIT_TYPELIBCACHE' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(516) : error C2065: 'AfxUnlockGlobals' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(551) : warning C4273: 'protected: static struct AFX_CONNECTIONMAP const CCmdTarget::connectionMap' : inconsistent dll linkage.  dllexport assumed.
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(551) : error C2491: 'CCmdTarget::connectionMap' : definition of dllimport static data member not allowed
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(590) : warning C4273: 'protected: static struct AFX_OLECMDMAP const CCmdTarget::commandMap' : inconsistent dll linkage.  dllexport assumed.
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(590) : error C2491: 'CCmdTarget::commandMap' : definition of dllimport static data member not allowed
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(701) : error C2065: 'afxData' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(701) : error C2228: left of '.hbmMenuDot' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(704) : error C2228: left of '.hbmMenuDot' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(706) : error C2228: left of '.hbmMenuDot' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(732) : error C2065: 'AfxSetWindowText' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(750) : error C2079: 'info' uses undefined struct 'AFX_CMDHANDLERINFO'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(751) : error C2228: left of '.pTarget' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(752) : error C2664: 'OnCmdMsg' : cannot convert parameter 4 from 'int *' to 'struct AFX_CMDHANDLERINFO *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(778) : error C2228: left of '.hbmMenuDot' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(809) : error C2228: left of '.hbmMenuDot' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(811) : error C2228: left of '.hbmMenuDot' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(815) : error C2228: left of '.hbmMenuDot' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(859) : warning C4273: 'public: static struct CRuntimeClass const CCmdTarget::classCCmdTarget' : inconsistent dll linkage.  dllexport assumed.
D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\CMDTARG.CPP(859) : error C2491: 'CCmdTarget::classCCmdTarget' : definition of dllimport static data member not allowed
Error executing cl.exe.

CMDTARG.OBJ - 71 error(s), 7 warning(s)
对于这种情况,还是和上面一样,就是工程文件中多了一个CMDTARG.CPP文件,同样这也是VC安装路径下的一个源文件。打开后会发现和上面一样的注释:
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-1998 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.

当然,也是MFC中几个函数的实现。

你可能感兴趣的:(vc++,ADO)