定义
_RecordsetPtr m_pRs 出错
摘录:
1.TestDoc.h
/////////////////////////////////////////////////////////////////
private: IADORecordBinding* m_piAdoRecordBinding;
CCustomRs m_rsRecSet;
CString m_strConnection;
CString m_strCmdText;
_RecordsetPtr m_pRs;2.TestDoc.cpp
//////////////////////////////////////////////////////////////////
BOOL CTestDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
m_strConnection=_T("Provider=MSDASQL.1;Data Source=mytest");
m_strCmdText=_T("select * from mytest"); ////////////就是下面这个m_pRS////////////////
m_pRs=NULL;
m_piAdoRecordBinding=NULL; // TODO: add reinitialization code here
// (SDI documents will reuse this document) return TRUE;
}3.Debug showing
////////////////////////////////////////////////////////////////
Compiling...
TestDoc.cpp
h:\my program\vc++\mfc\test\debug\msado15.tlh(409) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2146: syntax error : missing ';' before identifier 'm_pRs'
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2501: '_RecordsetPtr' : missing storage-class or type specifiers
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2501: 'm_pRs' : missing storage-class or type specifiers
H:\My program\VC++\MFC\Test\TestDoc.cpp(51) : error C2065: 'm_pRs' : undeclared identifier
Generating Code...
Compiling...
Test.cpp
h:\my program\vc++\mfc\test\debug\msado15.tlh(409) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2146: syntax error : missing ';' before identifier 'm_pRs'
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2501: '_RecordsetPtr' : missing storage-class or type specifiers
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2501: 'm_pRs' : missing storage-class or type specifiers
Generating Code...
Compiling...
TestView.cpp
h:\my program\vc++\mfc\test\debug\msado15.tlh(409) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2146: syntax error : missing ';' before identifier 'm_pRs'
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2501: '_RecordsetPtr' : missing storage-class or type specifiers
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2501: 'm_pRs' : missing storage-class or type specifiers
Generating Code...
Error executing cl.exe.Test.exe - 10 error(s), 3 warning(s)请问如何进行改正,谢谢!
_RecordsetPtr m_pRs 出错
摘录:
1.TestDoc.h
/////////////////////////////////////////////////////////////////
private: IADORecordBinding* m_piAdoRecordBinding;
CCustomRs m_rsRecSet;
CString m_strConnection;
CString m_strCmdText;
_RecordsetPtr m_pRs;2.TestDoc.cpp
//////////////////////////////////////////////////////////////////
BOOL CTestDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
m_strConnection=_T("Provider=MSDASQL.1;Data Source=mytest");
m_strCmdText=_T("select * from mytest"); ////////////就是下面这个m_pRS////////////////
m_pRs=NULL;
m_piAdoRecordBinding=NULL; // TODO: add reinitialization code here
// (SDI documents will reuse this document) return TRUE;
}3.Debug showing
////////////////////////////////////////////////////////////////
Compiling...
TestDoc.cpp
h:\my program\vc++\mfc\test\debug\msado15.tlh(409) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2146: syntax error : missing ';' before identifier 'm_pRs'
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2501: '_RecordsetPtr' : missing storage-class or type specifiers
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2501: 'm_pRs' : missing storage-class or type specifiers
H:\My program\VC++\MFC\Test\TestDoc.cpp(51) : error C2065: 'm_pRs' : undeclared identifier
Generating Code...
Compiling...
Test.cpp
h:\my program\vc++\mfc\test\debug\msado15.tlh(409) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2146: syntax error : missing ';' before identifier 'm_pRs'
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2501: '_RecordsetPtr' : missing storage-class or type specifiers
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2501: 'm_pRs' : missing storage-class or type specifiers
Generating Code...
Compiling...
TestView.cpp
h:\my program\vc++\mfc\test\debug\msado15.tlh(409) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2146: syntax error : missing ';' before identifier 'm_pRs'
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2501: '_RecordsetPtr' : missing storage-class or type specifiers
h:\my program\vc++\mfc\test\testdoc.h(59) : error C2501: 'm_pRs' : missing storage-class or type specifiers
Generating Code...
Error executing cl.exe.Test.exe - 10 error(s), 3 warning(s)请问如何进行改正,谢谢!
解决方案 »
- 急、急,请高手过来帮忙啊,怎么将缓冲区数据保存到图像,分不多,请多包涵。
- 请问怎样拦截.dll文件中调用某个函数后弹出的消息框?谢谢!!
- 大家看看面的的画线代码,为什么线总是从0,0点画出,而不是我指定的300,40
- 关于vc 开发dll的问题:返回string的问题,帮忙?
- com中字符串的问题
- MFC运行的问题?!
- 用ATL编写的一个Windows NT 标准服务,安装程序怎么做?
- 如何获取当前时间的前N天的日期?
- 寻求关于QueryPerformanceFrequency&QueryPerformanceCounter函数的说明
- 请教GDI+的问题
- 模板的问题
- 键盘上的那个一按下就弹出开始菜单的那个按钮
#include "comdef.h"
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename ("EOF","ISEOF")然后初始化com组件
if(FAILED(::CoInitialize(NULL)))
return;
m_pConnection.CreateInstance(_uuidof(Connection));
m_pRecordset.CreateInstance(_uuidof(Recordset));
然后你在定义就行了
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")
但要注意不能放在stdAfx.h文件的开头,而应该放在所有include指令的后面。否则在编译时会出错。
程序在编译过程中,VC++会读出msado15.dll中的类型库信息,自动产生两个该类型库的头文件和实现文件msado15.tlh和msado15.tli(在您的Debug或Release目录下)。在这两个文件里定义了ADO的所有对象和方法,以及一些枚举型的常量等。我们的程序只要直接调用这些方法就行了,与使用MFC中的COleDispatchDriver类调用Automation对象十分类似。
using namespace ADODB; 如果没有该句需要
m_pConnection.CreateInstance(_uuidof(ADODB::Connection));
AfxOleInit();