123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #include "stdafx.h"
- #include "one.h"
- #include "oneDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- BEGIN_MESSAGE_MAP(COneApp, CWinApp)
-
-
-
-
- ON_COMMAND(ID_HELP, CWinApp::OnHelp)
- END_MESSAGE_MAP()
- COneApp::COneApp()
- {
-
-
- }
- COneApp theApp;
- BOOL COneApp::InitInstance()
- {
- AfxEnableControlContainer();
- AfxOleInit();
- HRESULT hr;
- try
- {
- hr = m_pConnection.CreateInstance("ADODB.Connection");
- if(SUCCEEDED(hr))
- {
- hr = m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.mdb","","",adModeUnknown);
-
- }
- }
- catch(_com_error e)
- {
- CString errormessage;
- errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage());
- AfxMessageBox(errormessage);
- }
-
-
-
-
- #ifdef _AFXDLL
- Enable3dControls();
- #else
- Enable3dControlsStatic();
- #endif
- COneDlg dlg;
- m_pMainWnd = &dlg;
- int nResponse = dlg.DoModal();
- if (nResponse == IDOK)
- {
-
-
- }
- else if (nResponse == IDCANCEL)
- {
-
-
- }
-
-
- return FALSE;
- }
- int COneApp::ExitInstance()
- {
-
- if(m_pConnection->State)
- m_pConnection->Close();
- return CWinApp::ExitInstance();
- }
|