|
// Implementation of the CConversionProviderCommand
#include "stdafx.h"
#include "SimpleDataObject.h"
#include "DataObjectRowset.h"
#include "IGetAsOLEDBRowset_i.c"
/////////////////////////////////////////////////////////////////////////////
// CConversionProviderCommand
HRESULT CConversionProviderCommand::Execute(
IUnknown *pUnkOuter,
REFIID riid,
DBPARAMS *pParams,
LONG *pcRowsAffected,
IUnknown **ppRowset)
{
// CSimpleDataObjectRowset *pRowset;
// CConversionProviderRowset* pRowset;
// return CreateRowset(pUnkOuter, riid, pParams, pcRowsAffected, ppRowset, pRowset);
ATLTRACE2(atlTraceDBProvider, 0, "CConversionProviderCommand::Execute()\n");
// This code must be here as the parameters are connected to the command's accessor, not
// the rowsets... and we dont copy the accessors across yet...
if (m_strCommandText == _T("CONVERT"))
{
// We must have a paramter passed to us.
if (!pParams ||
!pParams->pData ||
pParams->cParamSets != 1 ||
pParams->hAccessor == 0)
{
ATLTRACE2(atlTraceDBProvider, 0, "CConversionProviderCommand::Execute called with no parameters\n");
return E_FAIL;
}
DBACCESSORFLAGS dwAccessorFlags = 0;
ULONG cBindings = 0;
DBBINDING *prgBindings = 0;
HRESULT hr = GetBindings(pParams->hAccessor,
&dwAccessorFlags,
&cBindings,
&prgBindings );
if (hr != S_OK)
{
return E_FAIL;
}
// can it be anything other than an unknown?
VARIANT ¶m = *(VARIANT*)((unsigned char*)(pParams->pData) + prgBindings[0].obValue);
if (param.vt != VT_UNKNOWN)
{
return E_FAIL;
}
IUnknown *pUnk = param.punkVal;
// At this point we have a pointer to the object that we want to create a rowset on,
pUnk->AddRef();
// const IID IID__IGetAsOLEDBRowset = {0x0C60F1D3,0x0C52,0x11d3,{0x80,0x22,0x00,0x80,0x5F,0x9B,0x64,0x5A}};
_IGetAsOLEDBRowset *pGetAsRowset = 0;
hr = pUnk->QueryInterface(IID__IGetAsOLEDBRowset, (void**)&pGetAsRowset);
pUnk->Release();
if (SUCCEEDED(hr))
{
// we now have a pointer to the thing that knows how to give us a rowset...
// Make it so...
IUnknown *pOurUnknown = 0;
hr = QueryInterface(IID_IUnknown, (void**)&pOurUnknown);
if (SUCCEEDED(hr))
{
hr = pGetAsRowset->GetAsRowset(pOurUnknown, pUnkOuter, riid, pcRowsAffected, ppRowset);
pOurUnknown->Release();
}
pGetAsRowset->Release();
}
return hr;
}
return DB_E_NOTABLE;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Len has been programming for over 30 years, having first started with a
Sinclair ZX-80. Now he runs his own consulting company,
JetByte Limited and has a technical blog
here.
JetByte provides contract programming and consultancy services. We can provide experience in COM, Corba, C++, Windows NT and UNIX. Our speciality is the design and implementation of systems but we are happy to work with you throughout the entire project life-cycle. We are happy to quote for fixed price work, or, if required, can work for an hourly rate.
We are based in London, England, but, thanks to the Internet, we can work 'virtually' anywhere...
Please note that many of the articles here may have updated code available on Len's
blog and that the IOCP socket server framework is also available in a licensed, much improved and fully supported version, see
here for details.