📄 pretreatment.cpp
字号:
#include "stdafx.h"
//#include "afx.h"
#include <cstring>
#include "pretreatment.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////
Pretreatment::Pretreatment():other(0)
{}
////////////////////////////////////////////////////
//初始化数据库连接
bool Pretreatment::InitDB()
{
::CoInitialize(NULL); //初始化
HRESULT hr;
try
{
//实例化连接对象
hr=m_pConnection.CreateInstance(__uuidof(Connection));
if(SUCCEEDED(hr))
{
//设置连接串属性为UDL文件
m_pConnection->ConnectionString="File Name=my_data1.udl";
//设置等待连接打开的时间为20秒
m_pConnection->ConnectionTimeout=20;
hr=m_pConnection->Open("","","",adConnectUnspecified);
if(FAILED(hr))
{
cout<<"open fail!"<<endl;
return TRUE;
}
}
else
{
cout<<"createinstance of Connection fail!"<<endl;
return TRUE;
}
}
catch (_com_error e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
cout<<bstrSource+bstrDescription<<endl;
return TRUE;
}
::CoUninitialize();
}
/////////////////////////////////////////////
////////////清除jpg,gif,css数据/////////////
////////////////////////////////////////////
void Pretreatment::clear_redundance()
{
HRESULT hr;
_RecordsetPtr pRentRecordset;
hr=pRentRecordset.CreateInstance(__uuidof(Recordset));
if(FAILED(hr))
{
cout<<"createinstance of Recordset failed!\n can`t initiate List control!"<<endl;
return;
}
CString strSql;
_variant_t var;
CString strValue;
int curItem=0;
strSql="SELECT * FROM logdb";
try
{
hr=pRentRecordset->Open(_variant_t(strSql),
m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
if(SUCCEEDED(hr))
{
cout<<"已经成功删除表内jpg等数据!"<<endl;
}
else
{
cout<<"Open recordset fail!"<<endl;
}
}
catch(_com_error *e)
{
cout<<e->ErrorMessage();
return;
}
pRentRecordset->Close();
pRentRecordset=NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -