?? commandptr.cpp
字號(hào):
// CommandPtr.cpp: implementation of the CCommandPtr class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "OilTrans.h"
#include "CommandPtr.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CCommandPtr::CCommandPtr()
{
sDatabase = "";
}
CCommandPtr::~CCommandPtr()
{
}
void CCommandPtr::SetDB(CString sDB)
{
sDatabase = sDB;
}
BOOL CCommandPtr::Open()
{
if(sDatabase == "")
{
AfxMessageBox("數(shù)據(jù)庫(kù)名為空,請(qǐng)選擇數(shù)據(jù)庫(kù)!");
return FALSE;
}
AfxOleInit();
m_pConnection.CreateInstance(__uuidof(Connection));
// 在ADO操作中建議語(yǔ)句中要常用try...catch()來(lái)捕獲錯(cuò)誤信息,
// 因?yàn)樗袝r(shí)會(huì)經(jīng)常出現(xiàn)一些想不到的錯(cuò)誤。jingzhou xu
try
{
// 打開(kāi)本地Access庫(kù)Demo.mdb
m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=CT.mdb","","",adModeUnknown);
}
catch(_com_error e)
{
AfxMessageBox("數(shù)據(jù)庫(kù)連接失敗,確認(rèn)數(shù)據(jù)庫(kù)Demo.mdb是否在當(dāng)前路徑下!");
return FALSE;
}
// ---------------------------------------------------------------------------------------------------
return TRUE;
}
void CCommandPtr::Exit()
{
if(m_pConnection->State)
m_pConnection->Close();
m_pConnection= NULL;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -