?? login.cpp
字號:
// Login.cpp : implementation file
//
#include "stdafx.h"
#include "圖書管理系統(tǒng).h"
#include "Login.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLogin dialog
CLogin::CLogin(CWnd* pParent /*=NULL*/)
: CDialog(CLogin::IDD, pParent)
{
//{{AFX_DATA_INIT(CLogin)
m_user = _T("");
m_password = _T("");
m_server = _T("");
//}}AFX_DATA_INIT
}
void CLogin::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLogin)
DDX_Text(pDX, IDC_EDIT1, m_user);
DDX_Text(pDX, IDC_EDIT2, m_password);
DDX_Text(pDX, IDC_EDIT3, m_server);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLogin, CDialog)
//{{AFX_MSG_MAP(CLogin)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLogin message handlers
void CLogin::OnOK()
{
// TODO: Add extra validation here
UpdateData();
////////////連接數(shù)據(jù)庫//////////////
CString strConnection = "Provider=MSDAORA;Data Source=" + m_server +
";User ID=" + m_user + "; Password=" + m_password;
HRESULT hr;
try
{
hr = m_pConnection.CreateInstance("ADODB.Connection");///創(chuàng)建Connection對象
if(SUCCEEDED(hr))
{
hr = m_pConnection->Open((_bstr_t)strConnection,"","",-1);///連接數(shù)據(jù)庫
state=1;
}
}
catch(_com_error e)///捕捉異常
{ state=0;
CString errormessage;
errormessage.Format("連接數(shù)據(jù)庫失敗!\r\n錯誤信息:%s",e.ErrorMessage());
AfxMessageBox(errormessage);///顯示錯誤信息
}
CDialog::OnOK();
}
void CLogin::OnCancel()
{
// TODO: Add extra cleanup here
state=0;
CDialog::OnCancel();
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -