GetChunk Method

See Also    Example    Applies To

Returns all or a portion of the contents of a Memo or Long Binary CdbField object in the Fields collection of a CdbRecordset object.

Syntax

COleVariantGetChunk( LONG lOffset, LONG lBytes );

Parameters

Type Example Description
LONG lOffset A numeric expression that is the number of bytes to skip before copying begins.
LONG lBytes A numeric expression that is the number of bytes you want to return.

Remarks

GetChunk returns COleVariant whose type is set to the type of the accessed field. Use GetChunk to return a portion of the total data value at a time. You can use the AppendChunk method to reassemble the pieces.

If lOffset is 0, GetChunk begins copying from the first byte of the field.

If lBytes is greater than the number of bytes in the field, GetChunk returns the actual number of remaining bytes in the field.

Caution Use a Memo field for text and put binary data only in Long Binary fields. Doing otherwise will cause undesirable results.

Usage

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

CdbRecordset      rs;
CdbField         fld;
COleVariant      vVal;
...                           // Initialize recordset, etc.
fld = rs.Fields[0];            // Get a field. (Assume it's a 35-byte long string)
vVal = fld.GetChunk(5L, 25L);     // Skip 5 bytes, get the next 25 bytes.