环境组合 WinXP SP2 VS2002+ObjectArx2004+acad2004或acad2006 在stdafx.h中 #pragma warning(disable:4146) #import "C:\Program Files\Common Files\System\ado\msado15.dll" rename_namespace("ARXADO") rename("EOF","adoEOF"),rename("BOF","adoBOF"),rename("EOS","AdoEOS") using namespace ARXADO; #pragma warning(default:4146)
下面为函数调用,在Open时就Crash,找遍网上都没有答案, if(FAILED(::CoInitialize(NULL))) { AfxMessageBox("CoInitialize失败!"); return; } _ConnectionPtr m_pConnection; _RecordsetPtr m_pRecordset; m_pConnection.CreateInstance(__uuidof(Connection)); m_pRecordset.CreateInstance(__uuidof(Recordset)); CString m_strConnection; try { m_strConnection.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s",strMDBFileName); m_pConnection->Open((_bstr_t)m_strConnection,"","",adModeUnknown);//CAD 崩溃crash } catch(_com_error &e) { strError.Format("数据库连接失败!原因:%s",e.ErrorMessage()); return; } |