Microsoft KB Archive/191878

= HOWTO: Use CBulkRowset =

Article ID: 191878

Article Last Modified on 3/2/2005

-

APPLIES TO

 Microsoft OLE DB 2.7, when used with:  Microsoft Visual C++ 6.0 Enterprise Edition

 Microsoft Visual C++ 6.0 Professional Edition

 Microsoft Visual C++ 6.0 Standard Edition 

-

<div class="notice_section">

This article was previously published under Q191878

<div class="summary_section">

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.

<div class="moreinformation_section">

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: kbhowto kbconsumer kbmdacnosweep KB191878

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.