PRB: OLE DB Consumer Template Wizard Requires ATL ProjectID: Q190959
|
If you attempt to add an ATL OLE DB Consumer class (with the ATL Object Wizard) to a non-ATL Visual C++ MFC project, you are prompted to add ATL support to the project. If you choose No, the Wizard will not continue.
The ATL OLE DB Consumer classes do not require ATL support; however, the ATL Object Wizard requires an ATL project.
The ATL OLE DB Consumer classes do not require full ATL support. For
example, you can use an ATL OLE DB Consumer class in a console project that
does not have a global CComModule object and is not set up to be an ATL COM
.exe or .dll file.
If you want to add one or more OLE DB Consumer Template classes to a non-
ATL project, create a temporary ATL project to create the classes and then
manually transfer the class files to your non-ATL project. The ATL OLE DB
Consumer Template wizard creates a single .h file each time you run it.
Transfer the wizard-generated .h files to your actual project and then add
the following code to the main header in your project:
#include <atldbcli.h>
// You must call CoInitialize before the first call to an ATL
// OLE DB Consumer class or you will get an hresult of
// 0x0040cba8, which is "CoInitialize has not been called."
// Because this structure has global scope, it is constructed first
// and destroyed last and thus automatically handles the necessary
// COM initialization and termination calls.
struct HandleCOM
{
HandleCOM() { ::CoInitialize(NULL); }
~HandleCOM() { ::CoUninitialize(); }
} _HandleCOM_;
The wizard-generated ATL OLE DB Consumer Templates require only the
Atldbcli.h ATL header file in order to compile properly.
This behavior is by design.
Follow these steps to create a temporary ATL project:
Additional query words: kbTemplate kbATL kbDatabase kbOLEDB kbvc600
Keywords : kbtemplate kbATL kbDatabase kbOLEDB
Version : WINNT:6.0
Platform : winnt
Issue type : kbprb
Last Reviewed: August 5, 1999