PRB: OLE DB Consumer Template Wizard Requires ATL Project (190959)
The information in this article applies to:
- Microsoft OLE DB, when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q190959 SYMPTOMS
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.
CAUSE
The ATL OLE DB Consumer classes do not require ATL support; however, the
ATL Object Wizard requires an ATL project.
RESOLUTION
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.
STATUS
This behavior is by design.
| Modification Type: | Minor | Last Reviewed: | 3/2/2005 |
|---|
| Keywords: | kbConsumer kbDatabase kbDTL kbprb kbtemplate kbwizard KB190959 kbAudDeveloper |
|---|
|