Using an Existing ADO Recordset
To mix OLE DB consumer templates and Active Data Objects (ADO), use ADO to open a recordset (corresponding to a rowset in the OLE DB Consumer Templates). When you have a recordset, do the following to connect to an OLE DB rowset:
Call
QueryInterface
for theIRowset
andIAccessor
pointers.IRowset* lpRowset = NULL; IAccessor* lpAccessor = NULL; lpUnk->QueryInterface(IID_IRowset, (void**)&lpRowset); lpUnk->QueryInterface(IID_IAccessor, (void**)&lpAccessor);
Note
lpUnk points to the
IUnknown
object of the ADO recordset.Attach the accessor and rowset to their appropriate OLE DB consumer template classes.
CRowset rs; CAccessor accessor; accessor.AddAccessorInfo(0ul); // 0 is the ordinal of an ADO accessor rs.m_spRowset.Attach(lpRowset); // use the Attach method of CComPtr<> rs.SetAccessor(accessor);
See also
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for