⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rxrecordset.cpp

📁 短信防伪系统服务器端
💻 CPP
字号:
// RxRecordset.cpp: implementation of the CRxRecordset class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "EasyTradeService.h"
#include "RxRecordset.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CRxRecordset::CRxRecordset()
{	
}

CRxRecordset::~CRxRecordset()
{
}

CString CRxRecordset::GetSQL()
{
	return sRecordset;
}


void CRxRecordset::Close()
{
	rst->Close();
}

void CRxRecordset::GetErrors(_com_error eErrors)
{
	CString string;
	CFile file;
	
	file.Open("Error.Rxe",CFile::modeWrite|CFile::modeNoTruncate);
	
	ErrorsPtr pErrors=cnn->GetErrors();
	if (pErrors->GetCount()==0)	
	{
		string=(char*)(_bstr_t)eErrors.ErrorMessage();
		file.Write(string+"\r\n",string.GetLength()+1);
		MessageBox(NULL,"发生错误:\n\n"+string,"系统提示",MB_OK|MB_ICONEXCLAMATION);
	}
	else
	{
		for (int i=0;i<pErrors->GetCount();i++)
		{
			_bstr_t desc=pErrors->GetItem((long)i)->GetDescription();
			string=(char*)desc;
			file.Write(string+"\r\n",string.GetLength()+1);
			MessageBox(NULL,"发生错误:\n\n"+string,"系统提示",MB_OK|MB_ICONEXCLAMATION);
		}
	}
	file.Close();
}

_RecordsetPtr CRxRecordset::GetRecordset()
{
	return rst;	
}

int CRxRecordset::GetFieldCount()
{
	int count;
	try{
		count=rst->GetFields()->GetCount();
	}
	catch(...)
	{
		return -1;
	}
	return count;
}

bool CRxRecordset::Move(int nRecordNumber)
{
	try{
	rst->MoveFirst();
	rst->Move(nRecordNumber);
	}
	catch(_com_error&e)
	{
		this->GetErrors(e);
		return false;
	}
	return true;
}

bool CRxRecordset::MovePrevious()
{
	try{
	rst->MovePrevious();
	}
	catch(_com_error&e)
	{
		this->GetErrors(e);
		return false;
	}
	return true;
}

bool CRxRecordset::MoveLast()
{
	try{
	rst->MoveLast();
	}
	catch(_com_error&e)
	{
		this->GetErrors(e);
		return false;
	}
	return true;
}

bool CRxRecordset::MoveNext()
{
	try{
	rst->MoveLast();
	}
	catch(_com_error&e)
	{
		this->GetErrors(e);
		return false;
	}
	return true;
}

int CRxRecordset::GetRecordCount()
{
	int nCount=0;
	try{
		rst->MoveFirst();
	}
	catch(...)
	{
		return 0;
	}
	if(rst->_EOF)
		return 0;
	while (!rst->_EOF)
	{
		rst->MoveNext();
		nCount=nCount+1;	
	}
	rst->MoveFirst();
	return nCount;
}

bool CRxRecordset::Open(CString srecordset, UINT adCmd)
{
	try{
	 rst=cnn->Execute((_bstr_t)srecordset,NULL,adCmd);
	}
	catch(_com_error&e)
	{
		this->GetErrors(e);
		return false;
	}
	return true;
}

bool CRxRecordset::MoveFirst()
{
	try{
	rst->MoveFirst();
	}
	catch(_com_error&e)
	{
		this->GetErrors(e);
		return false;
	}
	
	return true;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -