Click here to Skip to main content
Rate this: bad
good
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
{
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 25-Oct-12 1:58am

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

  Print Answers RSS
0 OriginalGriff 515
1 Maciej Los 340
2 Richard MacCutchan 265
3 BillWoodruff 225
4 Mathew Soji 155
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411028.1 | Last Updated 25 Oct 2012
Copyright © CodeProject, 1999-2014
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