本文整理汇总了C++中CComQIPtr::Execute方法的典型用法代码示例。如果您正苦于以下问题:C++ CComQIPtr::Execute方法的具体用法?C++ CComQIPtr::Execute怎么用?C++ CComQIPtr::Execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComQIPtr
的用法示例。
在下文中一共展示了CComQIPtr::Execute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Open
BOOL COledbRecordset::Open(LPCTSTR pstrSQL, long lType /*= DB_OPEN_TYPE_FORWARD_ONLY*/, long lOptions /*= DB_OPTION_DEFAULT*/)
{
_ASSERTE(m_pDb==NULL || m_pDb->IsOpen());
_ASSERTE(!::IsBadStringPtr(pstrSQL,(UINT)-1));
HRESULT Hr;
// Close old recordset
Close();
m_nRowsAffected = 0;
// Create a new recordset
CComQIPtr<IDBCreateCommand> spCreate = m_pDb->m_spSession;
if( spCreate == NULL ) return FALSE;
CComPtr<ICommand> spCommand;
Hr = spCreate->CreateCommand(NULL, IID_ICommand, (LPUNKNOWN*) &spCommand);
if( FAILED(Hr) ) return _Error(Hr);
// Set type
COledbDatabase::_SetRecordsetType(spCommand, lType, lOptions);
// Set SQL
CComQIPtr<ICommandText> spText = spCommand;
_ASSERTE(spText);
USES_CONVERSION;
Hr = spText->SetCommandText(DBGUID_DBSQL, T2COLE(pstrSQL));
if( FAILED(Hr) ) return _Error(Hr);
// Execute...
Hr = spText->Execute(NULL, IID_IRowset, NULL, &m_nRowsAffected, (LPUNKNOWN*) &m_spRowset);
if( FAILED(Hr) ) return _Error(Hr);
// Bind columns
if( !_BindColumns() ) return FALSE;
return MoveNext();
}
示例2: ExecuteSQL
BOOL COledbDatabase::ExecuteSQL(LPCTSTR pstrSQL, long lType /*= DB_OPEN_TYPE_FORWARD_ONLY*/, long lOptions /*= DB_OPTION_DEFAULT*/, DWORD* pdwRowsAffected/*= NULL*/)
{
USES_CONVERSION;
HRESULT Hr;
if( pdwRowsAffected ) *pdwRowsAffected = 0;
CComQIPtr<IDBCreateCommand> spCreate = m_spSession;
if( spCreate == NULL ) return FALSE;
CComPtr<ICommand> spCommand;
Hr = spCreate->CreateCommand(NULL, IID_ICommand, (LPUNKNOWN*) &spCommand);
if( FAILED(Hr) ) return _Error(Hr);
_SetRecordsetType(spCommand, lType, lOptions);
CComQIPtr<ICommandText> spText = spCommand;
_ASSERTE(spText);
Hr = spText->SetCommandText(DBGUID_DBSQL, T2CW(pstrSQL));
if( FAILED(Hr) ) return _Error(Hr);
CComPtr<IRowset> spRowset;
Hr = spText->Execute(NULL, IID_IRowset, NULL, (LONG*) pdwRowsAffected, (LPUNKNOWN*) &spRowset);
if( FAILED(Hr) ) return _Error(Hr);
return TRUE;
}
示例3: Execute
STDMETHODIMP CPluginDebugCommand::Execute(VARIANT* vParam, IVariantObject** ppVariantObject)
{
CComQIPtr<IDebugCommand> pDebugCommand = m_pDebugCommand;
ATLASSERT(pDebugCommand);
CComVar vResult;
RETURN_IF_FAILED(pDebugCommand->Execute(vParam, &vResult));
GUID iidCommand = {0};
RETURN_IF_FAILED(m_pPluginInfo->GetId(&iidCommand));
if (ppVariantObject)
{
CComPtr<IUnknown> pPluginParserUnknown;
RETURN_IF_FAILED(m_pPluginManager->CreatePluginInstance(PNAMESP_DBGENGINE, PDBGTYPE_COMMAND_PARSER, iidCommand, &pPluginParserUnknown));
CComQIPtr<ICommandResultParser> pCommandResultParser = pPluginParserUnknown;
if (!pCommandResultParser)
return E_NOINTERFACE;
RETURN_IF_FAILED(pCommandResultParser->Parse(&vResult, ppVariantObject));
CComQIPtr<IInitializeWithPluginInfo> pInitializeWithPluginInfo = m_pDebugCommand;
if (pInitializeWithPluginInfo)
{
CComPtr<IPluginInfo> pPluginInfo;
RETURN_IF_FAILED(pInitializeWithPluginInfo->GetPluginInfo(&pPluginInfo));
CComQIPtr<IVariantObject> pSourceVariantObject = pPluginInfo;
if (pSourceVariantObject)
{
CComVar v1;
if (pSourceVariantObject->GetVariantValue(VAR_COMMAND_TEXT, &v1) == S_OK)
{
RETURN_IF_FAILED((*ppVariantObject)->SetVariantValue(VAR_COMMAND_TEXT, &v1));
}
}
}
}
return S_OK;
}