【VC开源代码栏目提醒】:网学会员VC开源代码为您提供DBConnection.cpp参考,解决您在DBConnection.cpp学习中工作中的难题,参考学习。
// DBConnection.cpp: implementation of the CDBConnection class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ERSDemo.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)
{
::AfxMessageBox(e.ErrorMessage());
return FALSE;
}
}
void CDBConnection::Close()
{
m_pConn->Close();
m_Actived = FALSE;
}
上一篇:
FMMAIN.frm
下一篇:
高中政治教学中情境创设的尝试和思考