📄 dbconnect.cpp
字号:
// DBConnect.cpp: implementation of the CDBConnect class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "UserIn.h"
#include "DBConnect.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDBConnect::CDBConnect()
{
con.CreateInstance ("ADODB.Connection");
Actived=false;
}
CDBConnect::~CDBConnect()
{
con.Release ();
}
bool CDBConnect::Open (CString str)
{
try
{
con->Open (_bstr_t(str),"","",adConnectUnspecified);
Actived=true;
return true;
}
catch(_com_error &e)
{
::AfxMessageBox (e.ErrorMessage ());
for(long i=0;i<con->Errors ->Count ;i++)
{
AfxMessageBox(con->Errors ->GetItem (_variant_t(i))->Description );
}
return false;
}
}
void CDBConnect::Close ()
{
con->Close ();
Actived=false;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -