HOWTO: Use CBulkRowset

ID: Q191878


The information in this article applies to:


SUMMARY

The Visual C++ 6.0 OLE DB Consumer template classes contain a class called CBulkRowset. The CBulkRowset class allows you to retrieve multiple OLE DB HROWs in a single call to IRowset::GetNextRows. This optimizes traversing through a row set because when a function such as MoveNext() is called, the HROW has already been retrieved and a call to GetNextRows() is not necessary.

By default, the CBulkRowset tries to retrieve 10 HROWs at a time. You can change the number of HROWs that are retrieved by calling the CBulkRowset::SetRows().


MORE INFORMATION

The following sample code demonstrates how to use CBulkRowset:

Sample Code


   // sample.cpp
   // 

   #include <atlbase.h>
   #include <atldbcli.h>

   class CTable1Data
   {
      public:
      BSTR m_bstrField1;

      BEGIN_COLUMN_MAP(CTable1Data)
        COLUMN_ENTRY_TYPE(1, DBTYPE_BSTR, m_bstrField1)
      END_COLUMN_MAP()
   };

   int main(int argc, char* argv[])
   {
      CoInitialize(NULL);

      CCommand<CAccessor<CTable1Data>, CBulkRowset > cmd;
      CDataSource ds;

      // Open up data link dialog boxes to create a data source.
      ds.Open(GetDesktopWindow());

      CSession session;
      session.Open(ds);

      cmd.Open(session, "Select col1 from table1");
      cmd.MoveFirst();
      // Note that the CBulkRowset retrieved 10 HROWs at a time by default.
      // As a result, the MoveNext call does not have to make a GetNextRows
      // call to get the HROW because the first 10 HROWs have been
      // retrieved in the previous MoveFirst() call.
      cmd.MoveNext();

      cmd.Close();
      ds.Close();

      return 0;
   } 


Keywords          : kbATL kbOLEDB kbVC600 kbConsumer 
Version           : 
Platform          : 
Issue type        : kbhowto 

Last Reviewed: August 2, 1999