📄 rxado.cpp
字号:
// RxADO.cpp: implementation of the CRxADO class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "EasyTrade.h"
#include "RxADO.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
_ConnectionPtr cnn;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CRxADO::CRxADO()
{
}
CRxADO::~CRxADO()
{
}
void CRxADO::Close()
{
cnn->Close();
}
CString CRxADO::AutoNumber(CString sTable, CString sFieldName, CString sCode, int nStyle)
{
return "";
}
CString CRxADO::FieldToOtherField(CString cDataBaseName, CString cFieldName, CString cValue, CString cReturnField, int nStale)
{
return "";
}
bool CRxADO::SetConnection(CString LinkString)
{
::CoInitialize(NULL);
cnn=NULL;
cnn.CreateInstance(__uuidof(Connection));
cnn->ConnectionString=(_bstr_t)LinkString;
try{
cnn->Open(L"",L"",L"",adCmdUnspecified);
}
catch(_com_error& e)
{
ErrorsPtr pErrors=cnn->GetErrors();
if (pErrors->GetCount()==0)
{
CString ErrMsg=e.ErrorMessage();
MessageBox(NULL,"发生错误:\n\n"+ErrMsg,"系统提示",MB_OK|MB_ICONEXCLAMATION);
return false;
}
else
{
for (int i=0;i<pErrors->GetCount();i++)
{
_bstr_t desc=pErrors->GetItem((long)i)->GetDescription();
MessageBox(NULL,"发生错误:\n\n"+desc,"系统提示",MB_OK|MB_ICONEXCLAMATION);
return false;
}
}
}
return true;
}
_ConnectionPtr CRxADO::GetConnection()
{
return cnn;
}
int CRxADO::GetRecordCount(_RecordsetPtr pRst)
{
int nCount=0;
return nCount;
}
void CRxADO::GetADOErrors(_com_error eErrors)
{
ErrorsPtr pErrors=cnn->GetErrors();
if (pErrors->GetCount()==0)
MessageBox(NULL,eErrors.ErrorMessage(),"错 误",MB_OK|MB_ICONEXCLAMATION);
else
{
for (int i=0;i<pErrors->GetCount();i++)
{
_bstr_t desc=pErrors->GetItem((long)i)->GetDescription();
MessageBox(NULL,desc,"错 误",MB_OK|MB_ICONEXCLAMATION);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -