CdbRecordset::GetRows Method

Retrieves multiple rows from a Recordset object.

Syntax

COleVariantGetRows(LONG lRows=-1);

Parameters

Type Example Description
LONG lRows The number of rows to retrieve. The default is all rows.

Returns

GetRows returns a two-dimensional array into a COleVariant. The first subscript identifies the field and the second identifies the row number. Subscripts are zero-based.

Usage

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

CdbRecordset      rst;
COleVariant      vRows, vVal;
LONG            lIndex[2], lMax = 10;
HRESULT         hr;

...                           // Open a recordset, etc.
vRows = rst.GetRows(lMax);   // Get 10 rows from the recordset.
lIndex[0] = 0;               // Index the first field.
                           // Index rows 0 through 9.
for (lIndex[1] = 0; lIndex[1] < lMax; lIndex[1]++)
{                           // Get the field.
hr = SafeArrayGetElement(vRows.parray, &lIndex, &vVal);
...                           // Process the field in vVal.
}