PRB: C2664 Error When Using CNoAccessor (190981)
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 Q190981 SYMPTOMS
Using the CNoAccessor class as a template argument for CCommand or CTable
causes the following error:
atldbcli.h(2819) : error C2664: 'SetAccessor' : cannot convert
parameter 1 from 'class ATL::CAccessorRowset<class
ATL::CNoAccessor,class ATL::CRowset> *const ' to 'class
ATL::CAccessorBase *'
Types pointed to are unrelated; conversion requires reinterpret_cast,
C-style cast or function-style cast
For example, the following code causes the error to occur:
CCommand<CNoAccessor> cmd;
CAUSE
The second argument of the CCommand<> or CTable<> template is the rowset
class. By default, this is set to CRowset. The CRowset class assumes that
there will be an accessor used. Therefore, it is necessary to specify
CNoRowset or some other user-defined rowset class that doesn't rely on an
accessor.
RESOLUTION
To use CNoAccessor, specify "CNoRowset" for the rowset class argument of
the CCommand or CTable template classes.
The code resembles the following:
CCommand<CNoAccessor, CNoRowset>
If, for some reason, you need to specify CNoAccessor but still want some of
the functionality of the CRowset class, derive a new class from CRowset and
override any functions that rely on an accessor.
STATUS
This behavior is by design.
Modification Type: | Minor | Last Reviewed: | 3/2/2005 |
---|
Keywords: | kbConsumer kbDatabase kbDTL kbMDACNoSweep kbprb kbtemplate KB190981 kbAudDeveloper |
---|
|