How Do I Use Multiple Accessors?
Accessors are normally created using the BEGIN_COLUMN_MAP and END_COLUMN_MAP macros. This ensures that MoveNext will retrieve data for all specified columns automatically. In some instances, you may not want to retrieve all the columns on every move (for example, if one of the columns contains a large graphic). In that case, you can place one particular column in a separate accessor and make that a nonautomatic accessor, as shown below. When you call MoveNext, this code retrieves only the Product ID automatically. If you need the long name, you must call GetData explicitly, passing the accessor number (1, in this case) to retrieve the data.
class CProduct
{
public:
long nProductID;
char szVeryLongName[2048];
BEGIN_ACCESSOR_MAP(CProduct, 2) // Pass number of accessors
BEGIN_ACCESSOR(0, true) // true = an auto accessor
COLUMN_ENTRY(1, nProductID)
END_ACCESSOR()
BEGIN_ACCESSOR(1, false) // false = not an autoaccessor
COLUMN_ENTRY(2, szVeryLongName)
END_ACCESSOR()
END_ACCESSOR_MAP()
};