adorecordset.h

来自「基于UG平台」· C头文件 代码 · 共 139 行

H
139
字号
// ADORecordset.h: interface for the CADORecordset class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_ADORECORDSET_H__A9FA2F13_1E3F_4C34_B27A_18883F2AF115__INCLUDED_)
#define AFX_ADORECORDSET_H__A9FA2F13_1E3F_4C34_B27A_18883F2AF115__INCLUDED_

#include "ADODatabase.h"
#include <math.h>
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CADORecordset  
{
public:
	BOOL GetFieldValue(int nIndex, bool& bValue);
	BOOL GetFieldValue(CString lpFieldName, bool& bValue);
	bool GetFieldValue(int nIndex, CString& strValue, CString strDateFormat);
	bool GetFieldValue(CString lpFieldName, CString& strValue, CString strDateFormat);
	_RecordsetPtr GetActiveRecordset();
	CString GetFieldName(int nIndex);
	long GetFieldsCount(); // added by fengyuan
	enum cadoOpenEnum
	{
		openUnknown = 0,
		openQuery = 1,
		openTable = 2,
		openStoredProc = 3
	};

	enum cadoEditEnum
	{
		dbEditNone = 0,
		dbEditNew = 1,
		dbEdit = 2
	};
	
	enum cadoPositionEnum
	{
	
		positionUnknown = -1,
		positionBOF = -2,
		positionEOF = -3
	};
	
	enum cadoSearchEnum
	{	
		searchForward = 1,
		searchBackward = -1
	};

	CString LongToStr(long lVal);
	CString IntToStr(int nVal);
	CString ULongToStr(unsigned long ulVal);
	CString DblToStr(double dblVal, int ndigits);
	CString DblToStr(float fltVal);

	BOOL Update();
	void SetQuery(CString strQuery);
	void SetPageSize(int nSize);
	bool SetFieldValue(int nIndex, CString strValue);
	bool SetFieldValue(CString lpFieldName, CString strValue);
	bool SetFieldValue(int nIndex, int nValue);
	bool SetFieldValue(CString lpFieldName, int nValue);
	bool SetFieldValue(int nIndex, long lValue);
	bool SetFieldValue(CString lpFieldName, long lValue);
	bool SetFieldValue(int nIndex, double dblValue);
	bool SetFieldValue(CString lpFieldName, double dblValue);
	bool SetFieldValue(int nIndex, COleDateTime time);
	bool SetFieldValue(CString lpFieldName, COleDateTime time);

	bool SetBookmark();
	void SetAbsolutePosition(int nPosition);
	void SetAbsolutePage(int nPage);
	BOOL RecordBinding(CADORecordBinding &pAdoRecordBinding);
	int Open(_ConnectionPtr mpdb, CString lpstrExec = _T(""), int nOption = CADORecordset::openUnknown);
	int Open(CString lpstrExec = _T(""), int nOption = CADORecordset::openUnknown);
	void MovePrevious();
	void MoveNext();
	void MoveLast();
	void MoveFirst();
	bool IsOpen();
	bool IsFieldNull(int nIndex);
	bool IsFieldNull(CString lpFieldName);
	bool IsFieldEmpty(CString lpFieldName);
	BOOL IsFieldEmpty(int nIndex);
	BOOL IsEof();
	BOOL IsBof();
	CString GetString(CString lpCols, CString lpRows, CString lpNull, long numRows = 0);
	DWORD GetRecordCount();
	CString GetQuery();
	long GetPageSize();
	long GetPageCount();
	CString GetLastError(void);
	bool GetFieldValue(CString lpFieldName, COleDateTime& time);
	bool GetFieldValue(int nIndex, CString& strValue);
	bool GetFieldValue(CString lpFieldName, CString& strValue);
	bool GetFieldValue(int nIndex, int& nValue);
	bool GetFieldValue(CString lpFieldName, double& dbValue);
	bool GetFieldValue(int nIndex, long& lValue);
	bool GetFieldValue(int nIndex, COleDateTime& time);
	bool GetFieldValue(CString lpFieldName, long& lValue);
	BOOL GetFieldValue(int nIndex, double& dbValue);
	BOOL GetFieldValue(CString lpFieldName, int& nValue);
	BOOL GetFieldInfo(CString lpFieldName, CADOFieldInfo* fldInfo);
	BOOL GetFieldInfo(int nIndex, CADOFieldInfo* fldInfo);
	BOOL GetChunk(CString lpFieldName, CString& strValue);
	void GetBookmark();
	long GetAbsolutePosition();
	long GetAbsolutePage(void);
	BOOL FindNext(void);
	BOOL FindFirst(CString lpFind);
	bool Find(CString lpFind, int nSearchDirection = CADORecordset::searchForward);
	void Edit();
	BOOL Delete(void);
	void Close(void);
	void CancelUpdate(void);
	CADORecordset(CADODatabase* pAdoDatabase);
	BOOL AddNew(void);
	CADORecordset();
	virtual ~CADORecordset();

protected:
	_ConnectionPtr m_pConnection;
	int m_nSearchDirection;
	CString m_strFind;
	_variant_t m_varBookFind;
	_variant_t m_varBookmark;
	int m_nEditStatus;
	CString m_strLastError;
	void dump_com_error(_com_error &e);
	_RecordsetPtr m_pRecordset;
	_CommandPtr m_pCmd;
	CString m_strQuery;
};

#endif // !defined(AFX_ADORECORDSET_H__A9FA2F13_1E3F_4C34_B27A_18883F2AF115__INCLUDED_)

⌨️ 快捷键说明

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