arx+ado+acad2004 crash

arx+ado+acad2004 crash

Anonymous
Not applicable
592 Views
4 Replies
Message 1 of 5

arx+ado+acad2004 crash

Anonymous
Not applicable
I use VS2002 objectArx Acad2004 build arx.
when use ado open,Acad2004 or Acad2006 all crash.
the code:
//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)
//myfuntion ado open and acad2004 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);//ACAD crash
}
catch(_com_error &e)
{
strError.Format("connection open error:%s",e.ErrorMessage());
return;
}

someone can tell me why?
0 Likes
593 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
I had a similar problem when developing for 2005 and 2006 build.

I ended up with the following in my header file wher I utilized the code.


#include // Needed for _T() macro.

#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "adoEOF")
#define CATCHCOM(hr) if ( FAILED( hr ) ) throw( _com_error( hr, NULL ) );
// The BSTR's
_bstr_t connStrSQL("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=");
// The Coinitialize ( with out this struct it gets a invalid pointer error I don't know why)
struct HandleCOM
{
HandleCOM() { ::CoInitialize(NULL); }
~HandleCOM() { ::CoUninitialize(); }
} _HandleCOM_;
0 Likes
Message 3 of 5

Anonymous
Not applicable
I use VC6+ado+acad2002 code is right;
use VS2003+ado+acad2006(or acad2004) also right;
but VS2002+ado+acad2004(or acad2006) crash;
mybe vs2002 have some wrong.
I have update vs2002 sp1.
0 Likes
Message 4 of 5

Anonymous
Not applicable
My environment is VS 2002 with SP1 I believe. Idon't have that machine near me at the time though. I compiled for 2005 and 2006 with Object ARX 2005 though. I'm not sure if that made a difference though.

I've been looking into othe ways to tie to a database, sinc eI can't seemt o get this method to work with ObjectARX 2008 and VS 2005. I've managed to get some things to work but not sure about how efficient it is just yet. Have you looked into other methods?
0 Likes
Message 5 of 5

Anonymous
Not applicable
there is no error!!!!
0 Likes