Thursday, December 17, 2015

ATL OLE DB Provider Wizard Issues

There are some issues with the example ATL OLE DB Provider Wizard generated code that cost me some time when playing around with it today.

I thought I'd post my solutions in case it helps others.

  1. The generated code does not use the COM_INTERFACE_ENTRY2 macro properly - instead of the line of code on which you'll receive a compile error, you should have: COM_INTERFACE_ENTRY2(ICommand, ICommandText) -- notice, this is a reversal of the parameters. Apparently, the ATL macro changed the order of the arguments at some point in the past (or the sample code is just wrong). In any case, the base class goes on the left and the derived class on the right (not the way it was in the sample).
  2. The generated code includes PROVIDER_COLUMN_ENTRY_STR(...) for the column map in the C...WindowsFile class that is auto-generated in the ...RS.h file. If your project is compiled for UNICODE (as mine was), you need to make this PROVIDER_COLUMN_ENTRY_WSTR instead. You'll see the issue when you see only a single character for each of the file names (rather than the full file name) when using the provider.
Anyway, hope this helps anyone who runs into these issues.