📄 dbaccess2.cpp
字号:
// DBAccess.cpp: implementation of the CDBAccess class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "DBAccess2.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
CDBAccess2 DBAccess2;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDBAccess2::CDBAccess2()
{
}
CDBAccess2::~CDBAccess2()
{
delete pTable;
}
int CDBAccess2::InitDB(char *pszConnStr)
{
int nRetCode = 0;
pTable =new CAdoTable(pszConnStr);
int n = 0;
while(EV_ERR_OK != (nRetCode = pTable->ConnectDB()))
{
if(n > 3) break;
n++;
Sleep(1000);
}
return nRetCode;
}
int CDBAccess2::DBRequest(char *pszSvcCode, char *pszReqStr, char *pszRstStr)
{
memset(szSql,0,sizeof(szSql));
_snprintf(szSql, 256, "proc_csgp_get_data_%s %s", pszSvcCode, pszReqStr);
if(!pTable->ExcuteSql(szSql))
{
return -1;
}
int nRet = pTable->ReadField("RstData", pszRstStr);
if(nRet != EV_ERR_OK) return -2;
return 0;
}
int CDBAccess2::DealNoteSms(char *pszCallerID,char *pszCalledID)
{
//从表中得到短信内容
memset(szReturnStr,0,sizeof(szReturnStr));
memset(szSql,0,sizeof(szSql));
_snprintf(szSql, 256, "select top 1 RstData from tbl_hungsms_content where CalledID=\'%s\'",pszCalledID);
if(!pTable->ExcuteSql(szSql)){
return -1;
}
int nRet = pTable->ReadField("RstData", szReturnStr);
if(nRet != EV_ERR_OK) return -2;
memset(szSql,0,sizeof(szSql));
time_t nowTime_t;
time( &nowTime_t );
tm nt;
nt=*localtime( &nowTime_t );
CString strData;
strData.Format("%04d-%02d-%02d %02d:%02d:00",1900+nt.tm_year,nt.tm_mon,nt.tm_mday,nt.tm_hour,nt.tm_min);
_snprintf(szSql, 256, "insert into outbox (ExpressLevel,Sender,ReceiverMobileNo,Msg,SendTime,IsChinese) values(1,'szhd',\'%s\',\'%s\',\'%s\',1)",pszCallerID,szReturnStr,strData);
strData.Format("%s",szSql);
// _snprintf(szSql, 256, "insert into outbox (ExpressLevel,Sender,ReceiverMobileNo,Msg,SendTime,IsChinese) values(1,'szhd','13661103341','如果这都不算爱','2005-10-12 00:00:00',1)");
if(!pTable->ExcuteSql(szSql)){
return -1;
}
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -