dbconnection.cpp
来自「物资的入库、出库、借用和归还等。还提供日志 信息记录和报表显示功能」· C++ 代码 · 共 55 行
CPP
55 行
// 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 + =
减小字号Ctrl + -
显示快捷键?