Re: Sharing an ADO connection object between two processes ?
Brian Muth wrote:
HRESULT result = conn->QueryInterface(__uuidof(
ADODB::Connection,(void**)&conn);
Change to ADODB::_Connection
Brian
Thanks Brian, that made the difference.
If i pass the connection object in process to the following:
BYTE CServerDoc::SetConnect(IUnknown* conn)
{
ADOConnection* piTmpConnection;
HRESULT result = conn->QueryInterface(IID_IADOConnection,(LPVOID
*)&piTmpConnection);
if( result == E_NOINTERFACE )
return 0;
if( result == S_OK ){
ADORecordset* records;
result = CoCreateInstance(CLSID_CADORecordset, NULL,
CLSCTX_INPROC_SERVER, IID_IADORecordset,(LPVOID*)&records);
if(FAILED(result))
return 0;
result = records->Open(CComVariant((CComBSTR)"SELECT MEMBNO FROM
BASIC"),
CComVariant(piTmpConnection), adOpenKeyset,
adLockOptimistic, adCmdText);
if(FAILED(result))
return 0;
}
The everything is fine.
If i pass it remotely its fails when attempting to open the recordset.
If i change this line to
result = piTmpConnection->Execute((CComBSTR)"SELECT MEMBNO FROM
BASIC", NULL,adCmdUnspecified,&records);
Same thing.
I think this is enough to prove it does not work. Im not an expert on
COM, can anybody improve on what i have done?
Thanks for your help.