Click here to Skip to main content
11,806,575 members (39,717 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C++ OleDb
I got trouble when start creating accessor using attributes. I did like this class:

[db_source("my connection string")]
[db_command(" \
    SELECT \
        ProductId, \
        ProductName, \
        Company, \
        Code, \
        Quantity, \
        Price, \
        Description \
        FROM dbo.Products")]
class CProductsAccessor
    DWORD m_dwProductIdStatus;
    DWORD m_dwProductNameStatus;
    DWORD m_dwComapnyStatus;
    DWORD m_dwCodeStatus;
    DWORD m_dwQuantityStatus;
    DWORD m_dwPriceStatus;
    DWORD m_dwDescriptionStatus;
    DWORD m_dwProductIdLength;
    DWORD m_dwProductNameLength;
    DWORD m_dwCompanyLength;
    DWORD m_dwCodeLength;
    DWORD m_dwQuantityLength;
    DWORD m_dwPriceLength;
    DWORD m_dwDescriptionLength;
    [ db_column("1", status="m_dwProductIdStatus", length="m_dwProductIdLength") ]
    LONG m_ProductId;
    [db_column("2", status="m_dwProductNameStatus", length="m_dwProductNameLength")]
    TCHAR m_ProductName[51];
    [db_column("3", status="m_dwComapnyStatus", length="m_dwCompanyLength")]
    TCHAR m_Company[51];
    [db_column("4", status="m_dwCodeStatus", length="m_dwCodeLength")]
    TCHAR m_Code[51];
    [db_column("5", status="m_dwQuantityStatus", length="m_dwQuantityLength")]
    LONG m_Quantity;
    [db_column("6", status="m_dwPriceStatus", length="m_dwPriceLength")]
    double m_Price;
    [db_column("7", status="m_dwDescriptionStatus", length="m_dwDescriptionLength")]
    TCHAR m_Description[8000];
    void GetRowsetProperties(CDBPropSet* pPropSet)
      pPropSet->AddProperty(DBPROP_CANFETCHBACKWARDS, true);
      pPropSet->AddProperty(DBPROP_CANSCROLLBACKWARDS, true);
      pPropSet->AddProperty(DBPROP_IRowsetChange, true);
When I try to use this class:

CCommand<CAccessor<CProductsAccessor>> products;
I'm getting errors: ambiguous of 'm_nAccessor', ambiguous of 'SetAccessor', 'SetAccessor': indetifier not found. And how can I use this class in application? Please help me!!

I know that I can create this by ATL OLEDB Consumer wizard but I want to do it by hand with attributes
Posted 25-Oct-12 0:58am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 ppolymorphe 265
1 OriginalGriff 190
2 Richard Deeming 175
3 George Jonsson 125
4 Philippe Mori 80
0 OriginalGriff 3,380
1 Maciej Los 1,990
2 CPallini 1,915
3 KrunalRohit 1,907
4 ppolymorphe 1,317

Advertise | Privacy | Mobile
Web02 | 2.8.151002.1 | Last Updated 25 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100