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

📄 commandptr.cpp

📁 本程序是采用VC++和Mysql编写的一款油量换算软件
💻 CPP
字号:
// CommandPtr.cpp: implementation of the CCommandPtr class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "OilTrans.h"
#include "CommandPtr.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CCommandPtr::CCommandPtr()
{
	sDatabase = "";
    
}

CCommandPtr::~CCommandPtr()
{

}

void CCommandPtr::SetDB(CString sDB)
{
   sDatabase = sDB;
}

BOOL CCommandPtr::Open()
{
	if(sDatabase == "")
	{
		AfxMessageBox("数据库名为空,请选择数据库!");
		return FALSE;
	}
    AfxOleInit();
	m_pConnection.CreateInstance(__uuidof(Connection));
	// 在ADO操作中建议语句中要常用try...catch()来捕获错误信息,
	// 因为它有时会经常出现一些想不到的错误。jingzhou xu
	try                 
	{	
		// 打开本地Access库Demo.mdb
		m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=CT.mdb","","",adModeUnknown);
		
	}
	catch(_com_error e)
	{
		AfxMessageBox("数据库连接失败,确认数据库Demo.mdb是否在当前路径下!");
		return FALSE;
	} 
	// ---------------------------------------------------------------------------------------------------
    return TRUE;
}

void CCommandPtr::Exit()
{
    if(m_pConnection->State)
		m_pConnection->Close();
	m_pConnection= NULL;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -