|
///////////////////////////////////////////////////////////////////////////
//
// The code was borrowed from an article by Len Holgate
// www.codeproject.com/database/oledb-1.asp
//
///////////////////////////////////////////////////////////////////////////
#ifndef __I_COMMAND_WITH_PARAMETERS_IMPL__INCLUDED__
#define __I_COMMAND_WITH_PARAMETERS_IMPL__INCLUDED__
#include <atlcom.h>
#include <atldb.h>
///////////////////////////////////////////////////////////////////////////
// class ICommandWithPamametersImpl
template <class T>
class ATL_NO_VTABLE ICommandWithParametersImpl : public ICommandWithParameters
{
public:
STDMETHOD(GetParameterInfo)(
ULONG *pcParams,
DBPARAMINFO **prgParamInfo,
OLECHAR **ppNamesBuffer)
{
ATLTRACE2(atlTraceDBProvider, 0, "ICommandWithPamameterImpl::GetParametersInfo\n");
HRESULT hr = E_FAIL;
if (!pcParams || !prgParamInfo || !ppNamesBuffer)
{
ATLTRACE2(atlTraceDBProvider, 0,
"ICommandWithPamameterImpl::GetParametersInfo: - Error - a pointer is null\n");
return E_INVALIDARG;
}
T *pT = 0;
*pcParams = 0;
// The way that we use the command parameters means that this never gets called...
return DB_E_PARAMUNAVAILABLE;
}
STDMETHOD(MapParameterNames)(
ULONG cParamNames,
const OLECHAR *rgParamnNames[],
LONG rgParamOrdinals[])
{
ATLTRACE2(atlTraceDBProvider, 0, "ICommandWithPamametersImpl::MapParameterNames\n");
if (0 == cParamNames)
{
return S_OK;
}
// The way that we use the command parameters means that this never gets called...
return E_FAIL;
}
STDMETHOD(SetParameterInfo)(
ULONG cParams,
const ULONG rgParamOrdinals[],
const DBPARAMBINDINFO rgParamBindInfo[])
{
ATLTRACE2(atlTraceDBProvider, 0, "ICommandWithPamametersImpl::SetParameterInfo\n");
if (0 == cParams)
{
return S_OK;
}
// We should really check to see that:
// cParams is 1,
// rgParamOrdinals[0] is 1
// rgParamBindInfo[0]->dwFlags is DBPARAMFLAGS_ISINPUT
// rgParamBindInfo[0]->pwszDataSourceType is "DBTYPE_IUNKNOWN"
return S_OK;
}
};
#endif // __I_COMMAND_WITH_PARAMETERS_IMPL__INCLUDED__
|
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.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here