?? sqlexec.cpp
字號:
//SQLExec.cpp
/**************************************************************************
* 文件名:SQLExec.cpp
*
* SQL語句處理以及COM錯誤分析:
*
* PrintComError(_com_error &e) - COM錯誤分析
* StringToInt(CString s) -字符串轉換為整型
* ExecSQL(LPCTSTR strSql) -執行數據庫語句
*
*
*************************************************************************/
#include "stdafx.h"
#include "SQLExec.h"
#include "..\AirMonitor.h"
void WINAPI PrintComError(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
// Print Com errors.
printf("Error\n");
printf("\tCode = %08lx\n", e.Error());
printf("\tCode meaning = %s\n", e.ErrorMessage());
printf("\tSource = %s\n", (LPCSTR) bstrSource);
printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
int StringToInt(CString s)
{
int nReturn = 0;
char cc[10];
wsprintf(cc, "%s", s);
nReturn = atoi(cc);
return nReturn;
}
void ExecSQL(LPCTSTR strSql)
{
_RecordsetPtr pRst = NULL;
TESTHR(pRst.CreateInstance(__uuidof(Recordset)));
CAirMonitorApp* pApp = (CAirMonitorApp*)AfxGetApp();
pApp->m_curConfig.ADOExec(pRst, _variant_t(strSql));
}
float StringToFloat(CString s)
{
float fReturn = 0;
char cc[10];
wsprintf(cc, "%s", s);
fReturn = (float)atof(cc);
return fReturn;
}
COleDateTime StringToTime(CString s)
{
int nYear, nMonth, nDay,nHour,nMinute,nSecond;
CString ss;
ss = s.Left(4);
nYear = StringToInt(ss);
ss = s.Mid(5,2);
nMonth = StringToInt(ss);
ss = s.Mid(8,2);
nDay = StringToInt(ss);
nHour = StringToInt("00");
nMinute = StringToInt("00");
nSecond = StringToInt("00");
COleDateTime t(nYear, nMonth, nDay,nHour, nMinute,nSecond);
return t;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -