資源簡介
在vc6下的一個系統(tǒng),主要用于影碟的出租,是一個比較簡單的系統(tǒng)。

代碼片段和文件信息
//Ado.cpp:數(shù)據(jù)庫的操作類的函數(shù)定義
#include?“stdafx.h“
#include?“Ado.h“
//////////////////////////////////////////////////////////////////////
//?ado類的函數(shù)定義
//////////////////////////////////////////////////////////////////////
//Ado::Ado()
//{ //dataSource=_T(““);
//}
//Ado::~Ado()
//{
//}
/////////////?初始化一默認(rèn)連接數(shù)據(jù)庫air
void??MyAdo::OnInitAdo()
{
//?初始化OLE/COM庫環(huán)境?
::CoInitialize(NULL);
try
{
//?創(chuàng)建Connection對象
m_pConnection.CreateInstance(“ADODB.Connection“);
//?設(shè)置連接字符串,必須是BSTR型或者_bstr_t類型
CString?strConnect?=?_T(“Provider=SQLOLEDB.1;Password=123456;Persist?Security?Info=True;User?ID=fuxing;Initial?Catalog=fuxing;Data?Source=20110702-1834“);
m_pConnection->Open((_bstr_t)strConnectL““L““adModeUnknown);
}
catch(_com_error?e) //?捕捉異常
{
AfxMessageBox(e.Description()); //?顯示錯誤信息
}
}
/////////////////?初始化指定(strConnect)的連接數(shù)據(jù)庫
void??MyAdo::OnInitAdo(CString?strConnect)
{
//?初始化OLE/COM庫環(huán)境?
::CoInitialize(NULL);
try
{
//?創(chuàng)建Connection對象
m_pConnection.CreateInstance(“ADODB.Connection“);
//?設(shè)置連接字符串,必須是BSTR型或者_bstr_t類型
m_pConnection->Open((_bstr_t)strConnectL““L““adModeUnknown);
}
catch(_com_error?e) //?捕捉異常
{
AfxMessageBox(e.Description()); //?顯示錯誤信息
}
}
////////////?執(zhí)行查詢。bstrSQL(執(zhí)行的SQL語句)
_RecordsetPtr&?MyAdo::GetRecordSet(_bstr_t?sql)
{
try
{
//?連接數(shù)據(jù)庫,如果Connection對象為空,則重新連接數(shù)據(jù)庫
if(m_pConnection==NULL)
OnInitAdo();
//?創(chuàng)建記錄集對象
m_pRecordset.CreateInstance(__uuidof(Recordset));
//?取得表中的記錄
m_pRecordset->Open(sqlm_pConnection.GetInterfacePtr()adOpenDynamicadLockOptimisticadCmdText);
}
catch(_com_error?e) //?捕捉異常
{
//?顯示錯誤信息
AfxMessageBox(e.Description());
}
//?返回記錄集
return?m_pRecordset;
}
///////////////?執(zhí)行SQL語句,Insert?Update?_variant_t
BOOL?MyAdo::ExecuteSQL(_bstr_t?sql)
{
try
{
//?是否已經(jīng)連接數(shù)據(jù)庫
if(m_pConnection?==?NULL)
OnInitAdo();
//?Connection對象的Execute方法:(_bstr_t?CommandText?
//?VARIANT?*?RecordsAffected?long?Options?)?
//?其中CommandText是命令字串,通常是SQL命令。
//?參數(shù)RecordsAffected是操作完成后所影響的行數(shù)?
//?參數(shù)Options表示CommandText的類型:adCmdText-文本命令;adCmdTable-表名
//?adCmdProc-存儲過程;adCmdUnknown-未知
m_pConnection->Execute(sqlNULLadCmdText);
return?true;
}
catch(_com_error?e) //?捕捉異常
{
AfxMessageBox(e.Description()); //?顯示錯誤信息
}
return?true;
}
/////////////結(jié)束連接
void?MyAdo::ExitConnect()
{
//?關(guān)閉記錄集和連接
if?(m_pRecordset?!=?NULL)
m_pRecordset->Close();
m_pConnection->Close();
//?釋放環(huán)境
::CoUninitialize();
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1548??2011-09-05?10:34??影碟出租系統(tǒng)1\zhuce.cpp
?????文件???????1158??2011-09-05?10:33??影碟出租系統(tǒng)1\hazhao.h
?????文件???????1192??2011-09-05?08:03??影碟出租系統(tǒng)1\Denglu1.h
?????文件???????1202??2011-09-05?14:38??影碟出租系統(tǒng)1\List1.h
?????文件???????1951??2011-09-05?15:58??影碟出租系統(tǒng)1\hazhao.cpp
?????文件???????7695??2011-09-15?11:43??影碟出租系統(tǒng)1\影碟出租系統(tǒng)1.clw
?????文件???????4409??2011-09-04?16:52??影碟出租系統(tǒng)1\ReadMe.txt
?????文件???????1347??2011-09-04?16:52??影碟出租系統(tǒng)1\影碟出租系統(tǒng)1.h
?????文件???????4195??2011-09-04?16:52??影碟出租系統(tǒng)1\影碟出租系統(tǒng)1.cpp
?????文件???????1054??2011-09-04?16:52??影碟出租系統(tǒng)1\StdAfx.h
?????文件????????215??2011-09-04?16:52??影碟出租系統(tǒng)1\StdAfx.cpp
?????文件???????1808??2011-09-06?16:15??影碟出租系統(tǒng)1\Zhudie.cpp
?????文件???????1163??2011-09-05?08:25??影碟出租系統(tǒng)1\Denglu.h
?????文件???????1446??2011-09-04?16:52??影碟出租系統(tǒng)1\影碟出租系統(tǒng)1Doc.h
?????文件???????1712??2011-09-04?16:52??影碟出租系統(tǒng)1\影碟出租系統(tǒng)1Doc.cpp
?????文件???????1311??2011-09-05?08:25??影碟出租系統(tǒng)1\Denglu.cpp
?????文件???????1467??2011-09-06?16:39??影碟出租系統(tǒng)1\Huandie.cpp
?????文件????????970??2011-09-05?14:38??影碟出租系統(tǒng)1\List1.cpp
?????文件????????534??2011-09-04?16:52??影碟出租系統(tǒng)1\影碟出租系統(tǒng)1.dsw
?????文件???????1156??2011-09-06?16:17??影碟出租系統(tǒng)1\Huandie.h
?????文件???????1231??2011-09-06?16:11??影碟出租系統(tǒng)1\Zhudie.h
?????文件???????1416??2011-09-15?11:41??影碟出租系統(tǒng)1\影碟出租系統(tǒng)1.plg
?????文件???????1154??2011-09-04?17:19??影碟出租系統(tǒng)1\zhuce.h
?????文件?????263168??2011-09-15?11:43??影碟出租系統(tǒng)1\影碟出租系統(tǒng)1.ncb
?????文件????????749??2011-09-03?20:45??影碟出租系統(tǒng)1\Ado.h
?????文件???????2795??2011-09-03?20:37??影碟出租系統(tǒng)1\Ado.cpp
?????文件??????90619??2010-11-09?22:51??影碟出租系統(tǒng)1\msado15.tlh
?????文件??????76614??2010-11-09?22:51??影碟出租系統(tǒng)1\msado15.tli
?????文件???????1227??2011-09-04?20:56??影碟出租系統(tǒng)1\ZHuce11.h
?????文件????????984??2011-09-04?20:56??影碟出租系統(tǒng)1\ZHuce11.cpp
............此處省略53個文件信息
- 上一篇:VC++定義一只紅色畫筆,繪制一個等邊五邊形
- 下一篇:DIB圖像的打開與保存顯示
評論
共有 條評論