Implementing IRowsetLocate

After modifying the inheritance of RMyProviderRowset, you need to implement the IRowsetLocate interface. You can find the interface definition in the Interface Summary of the OLE DB Programmer's Reference and in the OLEDB.H file in the OLE DB SDK include directory.

To implement this interface:

  1. Create a new file named RowLoc.h and add the file to the project.

  2. In RowLoc.h, create a class definition for IRowsetLocateImpl, derived from IRowset, and implement the class.

  3. Copy the methods for the interface from the OLE DB header file OLEDB.H to RowLoc.h. Change the HRESULT return codes to STDMETHOD and put parentheses around the method names, as shown in the following code.

  4. Complete the implementation (covered in the next topic).
////////////////////////////////////////////////////////////////////////
// RowLoc.h
// class IRowsetLocateImpl

template <class T>
class ATL_NO_VTABLE IRowsetLocateImpl : public IRowsetImpl<T> 
{
public:
   STDMETHOD (Compare)(HCHAPTER hReserved, ULONG cbBookmark1, 
      const BYTE * pBookmark1, ULONG cbBookmark2, const BYTE * 
          pBookmark2, DBCOMPARE * pComparison)
   {
      return S_OK;
   }

   STDMETHOD (GetRowsAt)(HWATCHREGION hReserved1, HCHAPTER hReserved2,
      ULONG cbBookmark, const BYTE * pBookmark, LONG lRowsOffset,
      LONG cRows, ULONG * pcRowsObtained, HROW ** prghRows)
   {
      return S_OK;
   }

   STDMETHOD (GetRowsByBookmark)(HCHAPTER hReserved, ULONG cRows,
      const ULONG rgcbBookmarks[], const BYTE * rgpBookmarks[],
      HROW rghRows[], DBROWSTATUS rgRowStatus[])
   {
      return S_OK;
   }

   STDMETHOD (Hash)(HCHAPTER hReserved, ULONG cBookmarks,
      const ULONG rgcbBookmarks[], const BYTE * rgpBookmarks[],
      DWORD rgHashedValues[], DBROWSTATUS rgBookmarkStatus[])
   {
      ATLTRACENOTIMPL("IRowsetLocateImpl::GetRowsByBookmark");
   }
};

In the next topic, you will see how to complete the implementation by adding bookmarks.