The User Record

The User Record provides the code and data structure that represents the column data for a rowset. A User Record can be created at compile time or at run time. When you create a Provider using the ATL Object Wizard, the wizard creates a default user record that looks like this:

class CWindowsFile:
   public WIN32_FIND_DATA
{
public:

BEGIN_PROVIDER_COLUMN_MAP(CWindowsFile)
   PROVIDER_COLUMN_ENTRY("FileAttributes", 1, dwFileAttributes)
   PROVIDER_COLUMN_ENTRY("FileSizeHigh", 2, nFileSizeHigh)
   PROVIDER_COLUMN_ENTRY("FileSizeLow", 3, nFileSizeLow)
   PROVIDER_COLUMN_ENTRY("FileName", 4, cFileName)
   PROVIDER_COLUMN_ENTRY("AltFileName", 5, cAlternateFileName)
END_PROVIDER_COLUMN_MAP()

};

The OLE DB Provider Templates handle all OLE DB specifics regarding interactions with the client. To acquire the column data needed for a response, the provider calls the GetColumnInfo function, which you must place in the User Record:

template <class T>
static ATLCOLUMNINFO* GetColumnInfo(T* pThis, ULONG* pcCols)

The PROVIDER_COLUMN_MAP macros aid in creating a GetColumnInfo function:

  • BEGIN_PROVIDER_COLUMN_MAP defines the function prototype and a static array of ATLCOLUMNINFO structures.

  • PROVIDER_COLUMN_ENTRY macro defines and initializes a single ATLCOUMNINFO.

  • END_PROVIDER_COLUMN_MAP closes the array and the function. It also places the array element count into the pcCols parameter.

When a User Record is created at run time, GetColumnInfo uses the pThis parameter to receive a pointer to a rowset or command instance. Commands and rowsets must support the IColumnsInfo interface, so column information can be obtained from this pointer.

You can explicitly override GetColumnInfo in the User Record, as shown here:

template <class T>
static ATLCOLUMNINFO* GetColumnInfo(T* pThis, ULONG* pcCols)

This is equivalent to:

static ATLCOLUMNINFO* GetColumnInfo(CommandClass* pThis, ULONG* pcCols)
static ATLCOLUMNINFO* GetColumnInfo(RowsetClass* pThis, ULONG* pcCols)

CommandClass and RowsetClass are the command and rowset that use the User Record.

For an additional example of how to override GetColumnInfo in a User Record, see Creating a Simple Read-Only Provider.

Back to the OLE DB Provider Template Architecture