?? connectiondb.cpp
字號:
// ConnectionDB.cpp: implementation of the CConnectionDB class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Rent.h"
#include "ConnectionDB.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
_ConnectionPtr CConnectionDB::ConnectionP=NULL;
CConnectionDB::CConnectionDB()
{
}
CConnectionDB::~CConnectionDB()
{
}
_ConnectionPtr CConnectionDB::Connectiondb()
{
HRESULT hr;
try
{
hr=ConnectionP.CreateInstance(__uuidof(Connection));
if(SUCCEEDED(hr))
{
hr=ConnectionP->Open("Provider=Microsoft.Jet.OLEDB.4.0;\
Data Source=DVDMS.mdb","","",adModeUnknown);
if(FAILED(hr))
{
AfxMessageBox("open fail");
return NULL;
}
}
else
{
AfxMessageBox("Createinstance of Connection fail!");
return NULL;
}
}
catch(_com_error e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
AfxMessageBox(bstrSource+bstrDescription);
return NULL;
}
return ConnectionP;
}
_ConnectionPtr CConnectionDB::GetConnectionPtr()
{
return ConnectionP;
}
void CConnectionDB::DeleteConnectionPtr()
{
ConnectionP->Close();
ConnectionP=NULL;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -