資源簡介
詳細看了這段代碼自解碼goose報文已經不是問題

代碼片段和文件信息
//?ADOConn.cpp:連接、訪問、關閉數據庫的類
/*
?*作者:王勝?
?*Email:hust_wsh@qq.com
?*日期:2011-6-14
?*版本v8
?*/
//數據庫連接字符串在此處定義
//////////////////////////////////////////////////////////////////////
#include?“stdafx.h“
#include?“ADOConn.h“
#include?“stdio.h“
#include???
#include?“ConDatabase.h“
#ifdef?_DEBUG
#undef?THIS_FILE
static?char?THIS_FILE[]=__FILE__;
//#define?new?DEBUG_NEW
#endif
extern?ADOConn*?g_pado;
//////////////////////////////////////////////////////////////////////
//?Construction/Destruction
//////////////////////////////////////////////////////////////////////
//構造函數
ADOConn::ADOConn()
{?
HRESULT?hr;
string?databse;
ifstream???fin(“database.cfg“);?//打開配置文件
getline(findatabse);
//sqlStringStruct?*sqlString=new?_sqlStringStruct;//初始化結構體指針
//GetConnection(“database.cfg“databse);
/*bstr_t?provider(sqlString->Provider.c_str());
_bstr_t?datasource(sqlString->DataSource.c_str());
_bstr_t?initialcatalog(sqlString->InitialCatalog.c_str());
_bstr_t?userid(sqlString->UserID.c_str());
_bstr_t?password(sqlString->Password.c_str());*/
try
{
hr=m_pConnection.CreateInstance(“ADODB.Connection“);
if?(SUCCEEDED(hr))
{
//m_pConnection->ConnectionTimeout=3;//設置等待超時3s
//_bstr_t?strConnect=provider+“;“+datasource+“;“+initialcatalog+“;“+userid+“;“+password+““;//連接字符串
m_pConnection->Open(_bstr_t(databse.c_str())““““adModeUnknown);//以寫的方式打開數據庫
}
}
catch(_com_error?e)
{
//char?errormessage[1024];
//memset(errormessage01024);
//sprintf(errormessage“連接數據庫失敗!\r\n錯誤信息:%s“e.ErrorMessage());
//:MessageBox(NULLerrormessage““0);///顯示錯誤信息
cout<<“服務器連接異常請檢查環境配置!“< cout<ription()<
Sleep(2000);
exit(5);
}
//free(sqlString);
}
ADOConn::~ADOConn()
{
m_pRecordset_GEN->Close?();
m_pConnection->Close?();
}
//初始化函數,連接數據庫,打開數據庫
//數據集獲取
_RecordsetPtr&?ADOConn::GetRecordSet(_bstr_t?bstrSQL)
{
try
{
m_pRecordset.CreateInstance(__uuidof(Recordset));
m_pRecordset->Open(bstrSQLm_pConnection.GetInterfacePtr()adOpenDynamicadLockOptimisticadCmdText);
}
catch(_com_error?e)
{
cout<ription()< }
return?m_pRecordset;
}
//執行sql語句
BOOL?ADOConn::ExecuteSQL(_bstr_t?bstrSQL)
{
_variant_t?RecordsAffected;
try
{
m_pConnection->Execute(bstrSQLNULLadCmdText);
return?true;
}
catch(_com_error?e)
{
cout<ription()< return?false;
}
}
//void?ConnDatabase(int?idint?stnumchar?*uctimeDataSetEntryList?*dataSetEntryList)
//{
// _bstr_t?vSQLsql;
// /************************************************************************/
// /*?將值轉換過來?????????????????????????????????????????????????????????*/
// _bstr_t?stnumt(stnum);
// _bstr_t?uctimet(uctime);
// _bstr_t?stval(dataSetEntryList->stval);
// _bstr_t?intval(dataSetEntryList->intval);
// _bstr_t?floatval(dataSetEntryList->floatval);
// _bstr_t?bitstring(dataSetEntryList->bitstring);
// /**********
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????82??2011-08-25?17:05??GOOSE(能夠接收intfloatingstvaltime)\databa
?????文件?????????83??2011-08-26?09:15??GOOSE(能夠接收intfloatingstvaltime)\Debug\databa
?????文件?????????81??2011-08-25?11:22??GOOSE(能夠接收intfloatingstvaltime)\Debug\databa
?????文件?????????48??2011-06-28?09:51??GOOSE(能夠接收intfloatingstvaltime)\Debug\GOOSE.cfg
?????文件?????108032??2011-08-29?17:06??GOOSE(能夠接收intfloatingstvaltime)\Debug\GOOSEcapture.exe
?????文件?????673204??2011-08-29?17:06??GOOSE(能夠接收intfloatingstvaltime)\Debug\GOOSEcapture.ilk
?????文件????1428480??2011-08-29?17:06??GOOSE(能夠接收intfloatingstvaltime)\Debug\GOOSEcapture.pdb
?????文件??????23533??2011-08-25?11:49??GOOSE(能夠接收intfloatingstvaltime)\Debug\Goose數據庫數據字典.docx
?????文件?????????17??2011-08-28?13:20??GOOSE(能夠接收intfloatingstvaltime)\Debug\table.cfg
?????文件???17116160??2011-08-29?17:08??GOOSE(能夠接收intfloatingstvaltime)\GOOSEcapature.ncb
?????文件????????899??2011-05-26?17:20??GOOSE(能夠接收intfloatingstvaltime)\GOOSEcapature.sln
????..A..H.?????80384??2011-08-29?17:08??GOOSE(能夠接收intfloatingstvaltime)\GOOSEcapature.suo
?????文件??????23879??2011-08-26?13:42??GOOSE(能夠接收intfloatingstvaltime)\Goose數據庫數據字典.docx
?????文件????7220224??2011-06-28?14:37??GOOSE(能夠接收intfloatingstvaltime)\RecGoose8.ncb
????..A..H.?????32256??2011-06-28?14:37??GOOSE(能夠接收intfloatingstvaltime)\RecGoose8.suo
?????文件???????6436??2011-08-29?15:41??GOOSE(能夠接收intfloatingstvaltime)\RecGooseMFC\ADOConn.cpp
?????文件???????1287??2011-08-29?15:39??GOOSE(能夠接收intfloatingstvaltime)\RecGooseMFC\ADOConn.h
?????文件???????4873??2011-08-29?16:35??GOOSE(能夠接收intfloatingstvaltime)\RecGooseMFC\ADOExecute.cpp
?????文件????????305??2011-08-29?16:12??GOOSE(能夠接收intfloatingstvaltime)\RecGooseMFC\ADOExecute.h
?????文件???????1732??2011-08-29?16:44??GOOSE(能夠接收intfloatingstvaltime)\RecGooseMFC\ChangFun.cpp
?????文件????????503??2011-08-29?16:39??GOOSE(能夠接收intfloatingstvaltime)\RecGooseMFC\ChangFun.h
?????文件???????1553??2011-07-01?11:35??GOOSE(能夠接收intfloatingstvaltime)\RecGooseMFC\ConDataba
?????文件????????452??2011-08-29?08:38??GOOSE(能夠接收intfloatingstvaltime)\RecGooseMFC\ConDataba
?????文件?????????83??2011-08-25?17:12??GOOSE(能夠接收intfloatingstvaltime)\RecGooseMFC\databa
?????文件?????201205??2011-08-29?17:06??GOOSE(能夠接收intfloatingstvaltime)\RecGooseMFC\Debug\ADOConn.obj
?????文件?????195397??2011-08-29?17:06??GOOSE(能夠接收intfloatingstvaltime)\RecGooseMFC\Debug\ADOExecute.obj
?????文件???????9966??2011-08-29?17:06??GOOSE(能夠接收intfloatingstvaltime)\RecGooseMFC\Debug\BuildLog.htm
?????文件????????663??2011-08-29?17:06??GOOSE(能夠接收intfloatingstvaltime)\RecGooseMFC\Debug\GOOSEcapture.exe.em
?????文件????????728??2011-08-29?17:06??GOOSE(能夠接收intfloatingstvaltime)\RecGooseMFC\Debug\GOOSEcapture.exe.em
?????文件????????621??2011-08-29?17:06??GOOSE(能夠接收intfloatingstvaltime)\RecGooseMFC\Debug\GOOSEcapture.exe.intermediate.manifest
............此處省略78個文件信息
- 上一篇:算法分析與設計東北大學
- 下一篇:西安交大智能控制課件
評論
共有 條評論