m_pRecordset->Open("SELECT * FROM users",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
这个地方,总是说 
error C2065: 'theApp' : undeclared identifier
error C2228: left of '.m_pConnection' must have class/struct/union type
也引入了#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF")

解决方案 »

  1.   

    也有这个:_ConnectionPtr m_pConnection;
      

  2.   

    是用向导生成的MFC程序吗?看看...app.h和...app.cpp文件中有没有声明和定义C...App theApp。
      

  3.   

    rror C2065: '_ConnectionPtr' : undeclared identifier
    D:\源程序\PMI\PMICertDlg.cpp(179) : error C2146: syntax error : missing ';' before identifier ' m_pConnection'
    D:\源程序\PMI\PMICertDlg.cpp(179) : error C2065: ' m_pConnection' : undeclared identifier
    D:\源程序\PMI\PMICertDlg.cpp(180) : error C2228: left of '.CreateInstance' must have class/struct/union type
    Error executing cl.exe.
    是关于数据库连接的问题
      

  4.   

    这个问题我遇到过,在这行代码所在的文件开头加上下面一行就行了:
    extern C****App theApp;           //把“****”换成你工程的名称就行了。
      

  5.   

    当你的变量,如:_ConnectionPtr m_pConnection;是在工程的App类中声明时,想在****.h和****.cpp(这里****含义同上)以外的其它文件中调用这个变量的话,就要通过App类的全局对象theApp来实现,extern关键字可以使你跨文件访问全局变量。
      

  6.   

    我的问题没问好啊!~~~~
    上午应付了过去,还得继续
    我是想用VC访问数据库,在Stdafx.h里引入#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF")
    然后在文件PMICertDlg.cpp中添加一个指向Connection对象的指针_ConnectionPtr m_pConnection;
    再用这个指针调用函数:m_pConnection->Open("driver={SQL Server};Server=59.71.72.227;DATABASE=certlink;UID=sa;PWD="",adModeUnknown);
     这些都是从网上找来的,编译就会报上而的错误,难道_ConnectionPtr 不能直接用吗?
      

  7.   

    _ConnectionPtr m_pConnection;
    上面这个是在哪个类中声明的?
      

  8.   

    m_pRecordset->Open("SELECT * FROM users",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
    ------------------------------------------------------------------------------------------------
    从上面这行代码来看,你的m_pConnection是在工程的App类中声明的。如果不是的话,按你后来说的是在类CPMICertDlg中声明的,那就用不着在它前面加theApp.来引用它了。
    你先在PMICertDlg.cpp开头加上下面这句试试:extern CPMICertApp theApp;