ATL and ADO Problem
Database
1
Posts
1
Posters
0
Views
1
Watching
-
I am writing an ATL component to do some data access using ATO. I want to pass a _RecordsetPtr pointer or a _ConnectionPtr to a ATL function. I use code like this:
STDMETHODIMP CMyAtlObject::ReadData(LPDISPATCH pAdoRecordset, BOOL *pbSuccess) { _RecordsetPtr pRecordsetPtr; if (FAILED(pAdoRecordset->QueryInterface(IID_IDispatch, (void**) &pRecordsetPtr))) { return S_FALSE; } // do somethign here with the recordset return S_OK; }
But this doesn't work. The recordset pointer gets closed during the function call. If I pass an _ConnectionPtr as LPDISPATCH, the pointer becomes invalid. So how can I pass valid ADO _RecordsetPtr's and _ConnectionPtr's to an ATL Object?