Esempio n. 1
0
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////			//////////////////////////////
int DBPool::InsertDB(char *chSQL)
{
	try 
	{
		COleVariant vtOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR);
		m_pConn->Execute(_bstr_t(chSQL),&vtOptional,-1);

	}catch(_com_error e)
	{
		_bstr_t bstrErr=e.Description();
		CString strErrInfo;
		strErrInfo.Format("Error Information :%s\n", (LPCSTR)bstrErr);
		//WriteLog(strErrInfo);
		return -1;
	}
	/*
	try
	{
		//设置查询命令
		m_pCommand->CommandText = chSQL;
		//执行查询命令
		m_pCommand->Execute(NULL , NULL , NULL);
	}
	catch(_com_error e)
	{
		_bstr_t bstrErr=e.Description();
		CString strErrInfo;
		strErrInfo.Format("Error Information :%s\n", (LPCSTR)bstrErr);
		//WriteLog(strErrInfo);
		return -1;
	}
	*/
	return 0;
}
Esempio n. 2
0
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////			//////////////////////////////
int DBPool::QueryDB(char *chSQL)
{
	try 
	{
		COleVariant vtOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR);
		 m_pRS=m_pConn->Execute(_bstr_t(chSQL),&vtOptional,-1);
		 //printf("\r\n");
		while(!m_pRS->EndOfFile)
		{
			CString s(m_pRS->Fields->GetItem(_variant_t("counter_name"))->Value.bstrVal);

			int a=m_pRS->Fields->GetItem(_variant_t("cntr_value"))->Value.intVal;
			//CString s1(m_pRS->Fields->GetItem(_variant_t("cntr_value"))->Value.);
			
			m_pRS->MoveNext();
			s.TrimRight(" ");
			s.Replace(" ","_");
			s.Replace("/","_");
		//	printf("%s=%d\r\n",s,a);
		}

	}catch(_com_error e)
	{
		_bstr_t bstrErr=e.Description();
		CString strErrInfo;
		strErrInfo.Format("Error Information :%s\n", (LPCSTR)bstrErr);
		//WriteLog(strErrInfo);
		return -1;
	}
	return 0;
}
Esempio n. 3
0
//执行SQL更新语句,如插入、更新、删除
inline bool CRegisterDialog::ExcuteSQL(CString strSQL)
{
	try
	{
		COleVariant vtOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR);
		theApp.m_pConnection->Execute(_bstr_t(strSQL),&vtOptional,-1);
	}
	catch(_com_error e)
	{
//		AfxMessageBox(e->ErrorMessage());
		throw e;
		return false;
	}
	return true;
}