none
Can I use ADO(not ADO.net) in C++/CLR windows form application? RRS feed

  • 问题

  • I'm transferring from VC6 to VC2010.

    After I created a C++/CLR windows form application, I added following in stdafx.h:

    #import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF")

    when I use ADO in form, for example as follows:

    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
    _ConnectionPtr pConnection;

    HRESULT hr1, hr2; 
    hr1 = pConnection.CreateInstance("ADODB.Connection");
    hr2 = pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=./inf/AppConfig.xls;Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1\"","","",adModeUnknown);
    }

    The exception is thrown:

    Exception: _CrtIsValidHeapPointer(pUserData)

    I know the bold line causes this exception, but what's the problem?

    Thanks!

     
    2012年6月19日 3:25

答案

全部回复