long ADOComm::Execute(ADODB::_CommandPtr &pCommand, const long lCommandTimeout) { // CommandTimeout if (lCommandTimeout >= 0) { pCommand->PutCommandTimeout(lCommandTimeout); } _variant_t varRecordsAffected; pCommand->PutRefActiveConnection(pConnection_); pCommand->Execute(&varRecordsAffected, &vtMissing, ADODB::adExecuteNoRecords); // NoRecords pCommand->PutRefActiveConnection(NULL); return (long)varRecordsAffected; }
void ADOComm::OpenRs(ADODB::_CommandPtr &pCommand, CursorLocationEnum adCursorLocation, const long lCommandTimeout) { if (lCommandTimeout >= 0) { pCommand->PutCommandTimeout(lCommandTimeout); } pCommand->PutRefActiveConnection(pConnection_); pConnection_->PutCursorLocation(adCursorLocation); _variant_t varRecordsAffected; pRecordset_ = pCommand->Execute(&varRecordsAffected, &vtMissing, pCommand->GetCommandType()); pCommand->PutRefActiveConnection(NULL); if (adCursorLocation != adUseServer) { pRecordset_->PutRefActiveConnection(NULL); } }
////////////////////////////////////////////////////////////////////// // Query Excute long ADOComm::Execute(const _bstr_t &bstrSql, const long lCommandTimeout, bool bPrepared) { ADODB::_CommandPtr pCommand; pCommand.CreateInstance(__uuidof(Command)); // CommandTimeout if (lCommandTimeout >= 0) { pCommand->PutCommandTimeout(lCommandTimeout); } pCommand->PutCommandType(ADODB::adCmdText); pCommand->PutCommandText(bstrSql); pCommand->PutPrepared(bPrepared ? VARIANT_TRUE : VARIANT_FALSE); _variant_t varRecordsAffected; pCommand->PutRefActiveConnection(pConnection_); pCommand->Execute(&varRecordsAffected, &vtMissing, ADODB::adExecuteNoRecords); // NoRecords pCommand->PutRefActiveConnection(NULL); return (long)varRecordsAffected; }
////////////////////////////////////////////////////////////////////// // Recordset Open void ADOComm::OpenRs(const _bstr_t &bstrSql, CursorLocationEnum adCursorLocation, const long lCommandTimeout, bool bPrepared) { ADODB::_CommandPtr pCommand; pCommand.CreateInstance(__uuidof(Command)); pCommand->PutCommandType(ADODB::adCmdText); pCommand->PutCommandText(bstrSql); pCommand->PutPrepared(bPrepared ? VARIANT_TRUE : VARIANT_FALSE); if (lCommandTimeout >= 0) { pCommand->PutCommandTimeout(lCommandTimeout); } pCommand->PutRefActiveConnection(pConnection_); pConnection_->PutCursorLocation(adCursorLocation); _variant_t varRecordsAffected; pRecordset_ = pCommand->Execute(&varRecordsAffected, &vtMissing, ADODB::adCmdText); pCommand->PutRefActiveConnection(NULL); if (adCursorLocation != adUseServer) { pRecordset_->PutRefActiveConnection(NULL); } }