facsega Creative Commons License 2001.12.25 0 0 9
Ingyen kod ? Nesztek !

#ifndef __MYATLEX_H_12345

#define __MYATLEX_H_12345



#ifndef __cplusplus

    #error ATL requires C++ compilation (use a .cpp suffix)

#endif



#include <atlbase.h>

#include <atlcom.h>

#include <oledberr.h>

#include <atldbcli.h>



template <class TAccessor = CNoAccessor, class TRowset = CRowset>

class CIxTable :

    public CAccessorRowset<TAccessor, TRowset>

{

public:

    CIxTable()

    {

        m_spRowsetIx = NULL;

    }



    ~CIxTable()

    {

        Close();

    }



    void Close()

    {

        if (m_spRowsetIx != NULL)

            m_spRowsetIx.Release();



        CAccessorRowset<TAccessor,
TRowset>::Close();

    }



    // Open a rowset on the passed name

    HRESULT Open(const CSession& session, LPCTSTR szTableName, LPCTSTR
szIxName, DBPROPSET* pPropSet = NULL)

    {

        USES_CONVERSION;

        DBID idTable;

        DBID    IndexID;



        idTable.eKind = DBKIND_NAME;

        idTable.uName.pwszName =
(LPOLESTR)T2COLE(szTableName);

        IndexID.eKind = DBKIND_NAME;

        IndexID.uName.pwszName =
(LPOLESTR)T2COLE(szIxName);



        // Check the session is valid

        ATLASSERT(session.m_spOpenRowset != NULL);

        HRESULT hr;



        hr =
session.m_spOpenRowset->OpenRowset(NULL, &idTable, &IndexID, GetIID(),

            (pPropSet) ? 1 : 0,
pPropSet, (IUnknown**)GetInterfacePtr());



        if (SUCCEEDED(hr)) {



            SetupOptionalRowsetInterfaces();



//            hr =
(*(IUnknown**)GetInterfacePtr())->QueryInterface(IID_IRowsetIndex, (void**)
&m_spRowsetIx);

            hr =
m_spRowset->QueryInterface(IID_IRowsetIndex, (void**) &m_spRowsetIx);

            if(FAILED(hr))

                AtlTraceErrorRecords(hr);



            // If we have output
columns then bind

            if
(_OutputColumnsClass::HasOutputColumns())

                hr
= Bind();

        }

        else

            AtlTraceErrorRecords(hr);



        return hr;

    }



    HRESULT Seek(int nAccessor = 0, DWORD cKeyValues = 1, DBSEEK
dwSeekOptions = DBSEEK_FIRSTEQ)

    {

        HRESULT hr;

        return hr =
m_spRowsetIx->Seek(GetHAccessor(nAccessor), cKeyValues, m_pAccessor->GetBuffer(),
dwSeekOptions);

    }



    CComPtr<IRowsetIndex> m_spRowsetIx;

};



#endif // __MYATLEX_H_12345

facsega

Előzmény: facsega (8)