-
大小: 4.32MB文件類(lèi)型: .rar金幣: 2下載: 0 次發(fā)布日期: 2023-10-16
- 語(yǔ)言: C/C++
- 標(biāo)簽: MFC??數(shù)據(jù)庫(kù)??ADO??
資源簡(jiǎn)介
基于VC6.0軟件平臺(tái),使用MFC建立應(yīng)用程序。通過(guò)ADO連接Access數(shù)據(jù)庫(kù)將數(shù)據(jù)導(dǎo)入到MFC界面中的listview空間中。并且可以在界面中對(duì)數(shù)據(jù)庫(kù)中的數(shù)據(jù)進(jìn)行添加和刪除操作。

代碼片段和文件信息
//?MSPRO.cpp?:?Defines?the?class?behaviors?for?the?application.
//
#include?“stdafx.h“
#include?“MSPRO.h“
#include?“MSPRODlg.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//?CMSPROApp
BEGIN_MESSAGE_MAP(CMSPROApp?CWinApp)
//{{AFX_MSG_MAP(CMSPROApp)
//?NOTE?-?the?ClassWizard?will?add?and?remove?mapping?macros?here.
//????DO?NOT?EDIT?what?you?see?in?these?blocks?of?generated?code!
//}}AFX_MSG
ON_COMMAND(ID_HELP?CWinApp::onhelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//?CMSPROApp?construction
CMSPROApp::CMSPROApp()
{
//?TODO:?add?construction?code?here
//?Place?all?significant?initialization?in?InitInstance
}
/////////////////////////////////////////////////////////////////////////////
//?The?one?and?only?CMSPROApp?object
CMSPROApp?theApp;
/////////////////////////////////////////////////////////////////////////////
//?CMSPROApp?initialization
BOOL?CMSPROApp::InitInstance()
{
AfxEnableControlContainer();
AfxOleInit();///初始化COM庫(kù)
////////////連接數(shù)據(jù)庫(kù)//////////////
HRESULT?hr;
try
{
hr?=?m_pConnection.CreateInstance(“ADODB.Connection“);///創(chuàng)建Connection對(duì)象
if(SUCCEEDED(hr))
{
hr?=?m_pConnection->Open(“Provider=Microsoft.Jet.OLEDB.4.0;Data?Source=?AdoData.mdb“““““adModeUnknown);///連接數(shù)據(jù)庫(kù)
//上面一句中連接字串中的Provider是針對(duì)ACCESS2000環(huán)境的,對(duì)于ACCESS97
//需要改為:Provider=Microsoft.Jet.OLEDB.3.51;??}
}
}
catch(_com_error?e)///捕捉異常
{
CString?errormessage;
errormessage.Format(“連接數(shù)據(jù)庫(kù)失敗!\r\n錯(cuò)誤信息:%s“e.ErrorMessage());
AfxMessageBox(errormessage);///顯示錯(cuò)誤信息
return?FALSE;
}?
//?Standard?initialization
//?If?you?are?not?using?these?features?and?wish?to?reduce?the?size
//??of?your?final?executable?you?should?remove?from?the?following
//??the?specific?initialization?routines?you?do?not?need.
#ifdef?_AFXDLL
Enable3dControls(); //?Call?this?when?using?MFC?in?a?shared?DLL
#else
Enable3dControlsStatic(); //?Call?this?when?linking?to?MFC?statically
#endif
CMSPRODlg?dlg;
m_pMainWnd?=?&dlg;
int?nResponse?=?dlg.DoModal();
if?(nResponse?==?IDOK)
{
//?TODO:?Place?code?here?to?handle?when?the?dialog?is
//??dismissed?with?OK
}
else?if?(nResponse?==?IDCANCEL)
{
//?TODO:?Place?code?here?to?handle?when?the?dialog?is
//??dismissed?with?Cancel
}
//?Since?the?dialog?has?been?closed?return?FALSE?so?that?we?exit?the
//??application?rather?than?start?the?application‘s?message?pump.
return?FALSE;
}
int?CMSPROApp::ExitInstance()?
{
//?TODO:?Add?your?specialized?code?here?and/or?call?the?base?class
if(m_pConnection->State)
m_pConnection->Close();?///如果已經(jīng)打開(kāi)了連接則關(guān)閉它
return?CWinApp::ExitInstance();
}
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件?????425984??2011-07-23?21:10??MSPRO\Adodata.mdb
?????文件??????90733??2010-11-09?22:51??MSPRO\Debug\msado15.tlh
?????文件??????76671??2010-11-09?22:51??MSPRO\Debug\msado15.tli
?????文件????4252672??2011-07-23?21:06??MSPRO\Debug\MSPRO.bsc
?????文件?????131155??2011-07-23?21:06??MSPRO\Debug\MSPRO.exe
?????文件?????395240??2011-07-23?21:06??MSPRO\Debug\MSPRO.ilk
?????文件??????47130??2011-07-23?14:21??MSPRO\Debug\MSPRO.obj
?????文件????9538816??2011-07-22?20:24??MSPRO\Debug\MSPRO.pch
?????文件?????615424??2011-07-23?21:06??MSPRO\Debug\MSPRO.pdb
?????文件???????2992??2011-07-22?20:09??MSPRO\Debug\MSPRO.res
?????文件??????????0??2011-07-23?14:21??MSPRO\Debug\MSPRO.sbr
?????文件??????87042??2011-07-23?21:06??MSPRO\Debug\MSPRODlg.obj
?????文件??????????0??2011-07-23?21:06??MSPRO\Debug\MSPRODlg.sbr
?????文件?????133544??2011-07-22?20:24??MSPRO\Debug\StdAfx.obj
?????文件????1767056??2011-07-22?20:24??MSPRO\Debug\StdAfx.sbr
?????文件?????246784??2011-07-23?21:09??MSPRO\Debug\vc60.idb
?????文件?????561152??2011-07-23?21:06??MSPRO\Debug\vc60.pdb
?????文件??????90664??2010-11-09?22:51??MSPRO\msado15.tlh
?????文件??????76614??2010-11-09?22:51??MSPRO\msado15.tli
?????文件??????36252??2011-07-22?20:09??MSPRO\MSPRO.APS
?????文件???????1613??2011-07-23?21:33??MSPRO\MSPRO.clw
?????文件???????2940??2011-07-23?14:21??MSPRO\MSPRO.cpp
?????文件???????4215??2011-07-22?21:41??MSPRO\MSPRO.dsp
?????文件????????535??2011-07-22?19:51??MSPRO\MSPRO.dsw
?????文件???????1427??2011-07-23?09:58??MSPRO\MSPRO.h
?????文件?????140288??2011-07-23?21:33??MSPRO\MSPRO.ncb
?????文件??????55808??2011-07-23?21:33??MSPRO\MSPRO.opt
?????文件????????709??2011-07-23?21:06??MSPRO\MSPRO.plg
?????文件???????6084??2011-07-22?20:09??MSPRO\MSPRO.rc
?????文件???????8657??2011-07-23?21:06??MSPRO\MSPRODlg.cpp
............此處省略13個(gè)文件信息
評(píng)論
共有 條評(píng)論