ICommandImpl Class

Provides implementation for the ICommand interface.

Syntax

template <class T, class CommandBase = ICommand>
class ATL_NO_VTABLE ICommandImpl : public CommandBase

Parameters

T
Your class, derived from ICommandImpl.

CommandBase
A command interface. The default is ICommand.

Requirements

Header: atldb.h

Members

Methods

Name Description
Cancel Cancels the current command execution.
CancelExecution Cancels the current command execution.
CreateRowset Creates a rowset object.
Execute Executes the command.
GetDBSession Returns an interface pointer to the session that created the command.
ICommandImpl The constructor.

Data Members

Name Description
m_bCancel Indicates whether the command is to be canceled.
m_bCancelWhenExecuting Indicates whether the command is to be canceled when executing.
m_bIsExecuting Indicates whether the command is currently executing.

Remarks

A mandatory interface on the command object.

ICommandImpl::Cancel

Cancels the current command execution.

Syntax

STDMETHOD(Cancel)();

Remarks

See ICommand::Cancel in the OLE DB Programmer's Reference.

ICommandImpl::CancelExecution

Cancels the current command execution.

Syntax

HRESULT CancelExecution();

ICommandImpl::CreateRowset

Called by Execute to create a single rowset.

Syntax

template template <class RowsetClass>
HRESULT CreateRowset(IUnknown* pUnkOuter,
   REFIID riid,
   DBPARAMS* pParams,
   DBROWCOUNT* pcRowsAffected,
   IUnknown** ppRowset,
   RowsetClass*& pRowsetObj);

Parameters

RowsetClass
A template class member representing the user's rowset class. Usually generated by the wizard.

pUnkOuter
[in] A pointer to the controlling IUnknown interface if the rowset is being created as part of an aggregate; otherwise, it is null.

riid
[in] Corresponds to riid in ICommand::Execute.

pParams
[in/out] Corresponds to pParams in ICommand::Execute.

pcRowsAffected
Corresponds to pcRowsAffected in ICommand::Execute.

ppRowset
[in/out] Corresponds to ppRowset in ICommand::Execute.

pRowsetObj
[out] A pointer to a rowset object. Typically this parameter is not used, but it can be used if you must perform more work on the rowset before passing it to a COM object. The lifetime of pRowsetObj is bound by ppRowset.

Return Value

A standard HRESULT value. See ICommand::Execute for a list of typical values.

Remarks

To create more than one rowset, or to provide your own conditions for creating different rowsets, place different calls to CreateRowset from within Execute.

See ICommand::Execute in the OLE DB Programmer's Reference.

ICommandImpl::Execute

Executes the command.

Syntax

HRESULT Execute(IUnknown* pUnkOuter,
   REFIID riid,
   DBPARAMS* pParams,
   DBROWCOUNT* pcRowsAffected,
   IUnknown** ppRowset);

Parameters

See ICommand::Execute in the OLE DB Programmer's Reference.

Remarks

The outgoing interface requested will be an interface acquired from the rowset object that this function creates.

Execute calls CreateRowset. Override the default implementation to create more than one rowset or to provide your own conditions for creating different rowsets.

ICommandImpl::GetDBSession

Returns an interface pointer to the session that created the command.

Syntax

STDMETHOD (GetDBSession) (REFIID riid,
   IUnknown** ppSession);

Parameters

See ICommand::GetDBSession in the OLE DB Programmer's Reference.

Remarks

Useful for retrieving properties from the session.

ICommandImpl::ICommandImpl

The constructor.

Syntax

ICommandImpl();

ICommandImpl::m_bCancel

Indicates whether the command is canceled.

Syntax

unsigned m_bCancel:1;

Remarks

You can retrieve this variable in the Execute method of your command class and cancel as appropriate.

ICommandImpl::m_bCancelWhenExecuting

Indicates whether the command can be canceled when executing.

Syntax

unsigned m_bCancelWhenExecuting:1;

Remarks

Defaults to true (can be canceled).

ICommandImpl::m_bIsExecuting

Indicates whether the command is currently executing.

Syntax

unsigned m_bIsExecuting:1;

Remarks

The Execute method of your command class can set this variable to true.

See also

OLE DB Provider Templates
OLE DB Provider Template Architecture