try
{
m_pConnection.CreateInstance("ADODB.Connection");   //创建连接对象实例
// _bstr_t strConnect="DRIVER={Microsoft Access Driver (*.mdb)};\
uid=;pwd=;DBQ=Database.mdb;";
        // m_pConnection->Open(strConnect,"","",adModeUnknown);  //打开数据 CString str="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db_Video.mdb;Persist Security Info=False";
m_pConnection->ConnectionString=str.AllocSysString();
m_pConnection->Open("","","",-1);
}
catch(_com_error e)
{
        AfxMessageBox(e.Description());
}
已经AfxOleInit()初始化库,我都快烦死,连接别的数据库也一样,我是win7,vc++6.0。
调试运行提示Unhandled exception in *.exe 0xC000005:Access Violation 警告。

解决方案 »

  1.   

    m_pConnection->ConnectionString=str.GetBuffer()
      

  2.   

    调试运行提示:Unhandled exception in *.exe (KERNELBASE.DLL):
    oXE06D7363:Microsoft C++ Exception 错误。
     Call Stack: KERNELBASE ! 75a5d36f()中停止
      

  3.   


    不要看这个调用栈 Call Stack: KERNELBASE ,往下找你程序的代码函数
    就可以定位到代码错误了。
      

  4.   

    这句有问题:m_pConnection->ConnectionString=str.AllocSysString();改成:
       m_pConnection->ConnectionString=(_bstr_t)(LPCTSTR)str;