To use a static accessor (that is, an accessor derived from CAccessor), your consumer must have a user record. The user record is a C++ class that contains data elements to handle input or output. The ATL OLE DB Consumer Wizard generates a user record for your consumer. You can add methods to the user record for optional tasks like handling commands.
The following code shows a sample record that handles commands. In the user record, BEGIN_COLUMN_MAP represents a data rowset passed to the consumer from a provider. BEGIN_PARAM_MAP represents a set of command parameters. This example uses a
For more information about the COLUMN_MAP and PARAM_MAP macros, see
В | ![]() |
---|---|
class CArtists { public: // Data Elements CHAR m_szFirstName[20]; CHAR m_szLastName[30]; short m_nAge; // Column binding map BEGIN_COLUMN_MAP(CArtists) COLUMN_ENTRY(1, m_szFirstName) COLUMN_ENTRY(2, m_szLastName) COLUMN_ENTRY(3, m_nAge) END_COLUMN_MAP() // Parameter binding map BEGIN_PARAM_MAP(CArtists) COLUMN_ENTRY(1, m_nAge) END_PARAM_MAP() }; |
Wizard-Generated User Records
If you use the ATL OLE DB Consumer Wizard to generate a consumer, you have the choice of using OLE DB Templates or OLE DB Attributes. The generated code is different in each case. For more information about this code, see Consumer Wizard-Generated Classes.
User Record Support for Multiple Accessors
For a detailed discussion of the scenarios in which you need to use multiple accessors, see Using Multiple Accessors on a Rowset.
The following example shows the user record modified to support multiple accessors on the rowset. Instead of BEGIN_COLUMN_MAP and END_COLUMN_MAP, it uses
В | ![]() |
---|---|
class CMultiArtists { public: // Data Elements CHAR m_szFirstName[20]; CHAR m_szLastName[30]; short m_nAge; // Column binding map BEGIN_ACCESSOR_MAP(CMultiArtists, 2) BEGIN_ACCESSOR(0, true) // true specifies an auto accessor COLUMN_ENTRY(1, m_szFirstName) COLUMN_ENTRY(2, m_szLastName) END_ACCESSOR() BEGIN_ACCESSOR(1, false) // false specifies a manual accessor COLUMN_ENTRY(3, m_nAge) END_ACCESSOR() END_ACCESSOR_MAP() }; |