GetRowsEx Method

       

The GetRowsEx method retrieves multiple rows and allows you to specify the data types of the fields stored in your application variables.

The GetRowsEx method is a performance improvement by dbDAO and MFC DAO to avoid the necessity to retrieve all data as variants and then convert to native types.

Syntax

LONGGetRowsEx(LPVOID pvBuffer,

LONG cbRow,

LPDAORSETBINDING prb,

LONG cBinding,

LPVOID pvVarBuffer = NULL,

LONG cbVarBuffer = 0,

LONG lRows = -1);

Parameters

Type Argument Description
LPVOID pvBuffer Pointer to buffer in which to store returned rows.
LONG cbRow Length of row in bytes.
LPDAORSETBINDING prb Pointer to binding structure.
LONG cBinding Number of bindings.
LPVOID pvVarBuffer = NULL Optional. Pointer to buffer in which to store variable-length data.
LONG cbVarBuffer = 0 Optional. Length in bytes of pvVarBuffer.
LONG lRows Optional. Number of rows requested.

Remarks

GetRowsEx is only available in dbDAO.

The DAORSETBINDING structure specifies how data is to be copied from the rows to the memory buffer. A separate binding structure must be filled in for each field retrieved.

Note Each time GetRowsEx retrieves a set of records, it retrieves the last record of the previous set again. For example, if you retrieve five records at a time, GetRowsEx will first retrieve records 1 through 5. The next time it will retrieve records 5 through 10. The time after that, records 10 through 15, and so on. Notice that records 5 and 10 are retrieved twice.

Usage

#include <afxole.h>
#include <dbdao.h>

CdbRecordset      rst;
COleVariant      vRows;
int               n;
LONG            lIndex[2];
HRESULT         hr;
DAORSETBINDING   dsbind;
TCHAR            Buffer[512], VarBuffer[256];
...                        // Open a recordset, fill in binding                            // structure, etc.
vRows = GetRowsEx(&Buffer, cbRow, &dsbind, cBinding, 
                  &VarBuffer, sizeof(VarBuffer), 10);
lIndex[0] = 0;            // Index of the 1st field.
lIndex[1] = 1;            // Index of the 2nd row.
                        // Get the field (assume an integer).
hr = SafeArrayGetElement(vRows.parray, &lIndex, &n);