⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connectiondb.cpp

📁 影碟出租系统 利用mfc编程 与数据库连接
💻 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 + -