Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
{
public:
    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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900