
Exception fired during DLL unload in ATL com object
- thanks for trying, but Addref did not work.
i think it is not being released automatically because after returning
from the method call, the client gets the recordset and is able to
display it in a data grid.
- i also noticed that if i comment out all the recordset stuff (*all
the stuff that creates fields and appends records*) and just do a Detach
() immediately, the Exception does not occur. does it have to do with
how i create the fields and append records to it?
- also, i dont call Update() since i am not connected to any database.
is that right? how about a connection object, do i need it since i
really dont connect to any DB. i just return a recordset because the
client wants the result in a recordset.
- this is how i do the append, then add records :
rs->PutCursorLocation (adUseClient);
// create 2 fields of the recordset.
rs->Fields->Append (_bstr_t("Name"), adVarChar, 100, FieldAttribu{*filter*}um
(adFldUpdatable + adFldIsNullable));
rs->Fields->Append (_bstr_t("Value"), adVarChar, 255, FieldAttribu{*filter*}um
(adFldUpdatable + adFldIsNullable));
rs->Open (vtMissing, vtMissing, adOpenStatic, adLockOptimistic,
adOptionUnspecified);
while (/*some condition*/)
{
rs->AddNew ();
rs->GetFields()->GetItem((_bstr_t) "Name")->PutValue (pNameValue-
Quote:
>m_szName.c_str());
rs->GetFields()->GetItem((_bstr_t) "Value")->PutValue (pNameValue-
Quote:
>m_szValue.c_str());
}
*ppRecordset =3D rs.Detach (); // ppRecordSet is the _Recordset **
//[out] param and
Quote:
> I am not sure if this will work. But I remember that in some cases
you'd =
> need to=20
> AddRef the recordset pointer since it's a smart pointer. The AddRef
is =
> to make=20
> sure that it does not get released automatically.=20
> Good luck.
> Peter
> -----Original Message-----
> my COM object works fine, except for the fact that if the client calls
> a method that returns an ADO recordset, i get 'Exception fired during
> DLL unload'.
> what would be the right way to pass back ADO recordsets?
> My COM method passes back the recordset as [out, retval], and within
> that method, it calls another method from an object which gets the
> recordset as a param.
> STDMETHODIMP CMyInterface::MyMethod (BSTR bData, _Recordset**
> ppRecordset)
> {
> CMyClass x;
> _RecordsetPtr rs (__uuidof (adoRecordset));
> x.Foo (&rs); // x.Foo will create the fields and populate
> *ppRecordset = rs.Detach ();
> }
> CMyClass::Foo (_Recordset** prs)
> {
> _RecordsetPtr pRs (__uuidof(adoRecordset))
> *prs = NULL; // reset first;
> /* create the fields here and populate
> .
> .
> .
> */
> *prs =3D pRs.Detach ();
> }
> Sent via Deja.com
> http://www.*-*-*.com/
> .
Sent via Deja.com
http://www.*-*-*.com/