📄 dbconnection.cpp
字号:
// DBConnection.cpp: implementation of the CDBConnection class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "DBConnection.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDBConnection::CDBConnection()
{
//创建连接对象
m_pConn.CreateInstance("ADODB.Connection");
m_Actived = FALSE;
}
CDBConnection::~CDBConnection()
{
//释放连接对象
m_pConn.Release();
}
BOOL CDBConnection::Open(CString CnnStr)
{
try
{
m_pConn->Open(_bstr_t(CnnStr), "", "", adConnectUnspecified);
m_Actived = TRUE;
return TRUE;
}
catch(_com_error &e)
{
return FALSE;
}
}
void CDBConnection::Close()
{
if (m_Actived)
{
m_pConn->Close();
m_Actived = FALSE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -