Ejemplo n.º 1
0
ADODB::_CommandPtr  COracleDatabase::GetCommandPointer()
{
	ADODB::_CommandPtr spCommand;
	if (spCommand == NULL)
	{
		HRESULT hr = spCommand.CreateInstance(__uuidof(ADODB::Command));
		if (FAILED(hr))
		{
			return NULL;
		}
		m_pConnection->CursorLocation = ADODB::adUseClient;
		spCommand->ActiveConnection = m_pConnection;
		spCommand->CommandType = ADODB::adCmdStoredProc;
	}
	return spCommand;
}
Ejemplo n.º 2
0
//////////////////////////////////////////////////////////////////////
// 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;
}
Ejemplo n.º 3
0
//////////////////////////////////////////////////////////////////////
// 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); 
	}
}