?? adorecordset.h
字號:
//
/****************************************/
/* ADO封裝類設計AdoConnection */
/*設計者:全佳營 */
/*時間:2004.5.9-2004.5.18 */
/*Email:ghostman@tzc.edu.cn */
/*本ADO封裝類是參考網友提供的設計的 */
/****************************************/
#pragma once
#include "AdoConnection.h"
/*------------------------------------------------
CAdoRecordSet class
------------------------------------------------*/
class CAdoRecordSet
{
public:
CAdoRecordSet(void);
CAdoRecordSet(CAdoConnection *pConnection);
~CAdoRecordSet(void);
protected:
void Release();
// 屬性
public:
// 當前編輯狀態
EditModeEnum GetEditMode();
// 當前狀態
BOOL IsEOF();
BOOL IsBOF();
BOOL IsOpen();
long GetState();
long GetStatus();
// 光標位置
CursorLocationEnum GetCursorLocation();
BOOL SetCursorLocation(CursorLocationEnum CursorLocation = adUseClient);
// 光標類型
CursorTypeEnum GetCursorType();
BOOL SetCursorType(CursorTypeEnum CursorType = adOpenStatic);
// 書簽
_variant_t GetBookmark();
BOOL SetBookmark(_variant_t varBookMark = _variant_t((long)adBookmarkFirst));
// 當前記錄位置
long GetAbsolutePosition();
BOOL SetAbsolutePosition(int nPosition);
long GetAbsolutePage();
BOOL SetAbsolutePage(int nPage);
// 每頁的記錄數 ------------------------
long GetPageSize();
BOOL SetCacheSize(const long& lCacheSize);
// 頁數 --------------------------------
long GetPageCount();
// 記錄數及字段數 ----------------------
long GetRecordCount();
long GetFieldsCount();
// 查詢字符串 --------------------------
CString GetSQLText() {return m_strSQL;}
void SetSQLText(LPCTSTR strSQL) {m_strSQL = strSQL;}
// 連接對象 ----------------------------
CAdoConnection* GetConnection() {return m_pConnection;}
void SetAdoConnection(CAdoConnection *pConnection);
// 記錄集對象 --------------------------
_RecordsetPtr& GetRecordset();
CString GetLastError();
// 字段屬性 ----------------------------------------------
public:
// 字段集 -------------------------------
FieldsPtr GetFields();
// 字段對象 -----------------------------
FieldPtr GetField(long lIndex);
FieldPtr GetField(LPCTSTR lpszFieldName);
// 字段名 -------------------------------
CString GetFieldName(long lIndex);
// 字段數據類型 -------------------------
DataTypeEnum GetFieldType(long lIndex);
DataTypeEnum GetFieldType(LPCTSTR lpszFieldName);
// 字段屬性 -----------------------------
long GetFieldAttributes(long lIndex);
long GetFieldAttributes(LPCTSTR lpszFieldName);
// 字段實際長度
long GetFieldActualSize(long lIndex);
long GetFieldActualSize(LPCTSTR lpszFieldName);
// 字段是否為NULL
BOOL IsFieldNull(long index);
BOOL IsFieldNull(LPCTSTR lpFieldName);
// 記錄更改
public:
BOOL AddNew();
BOOL Update();
BOOL UpdateBatch(AffectEnum AffectRecords = adAffectAll);
BOOL CancelUpdate();
BOOL CancelBatch(AffectEnum AffectRecords = adAffectAll);
BOOL Delete(AffectEnum AffectRecords = adAffectCurrent);
// 刷新記錄集中的數據
BOOL Requery(long Options = adConnectUnspecified);
BOOL Resync(AffectEnum AffectRecords = adAffectAll, ResyncEnum ResyncValues = adResyncAllValues);
BOOL RecordBinding(CADORecordBinding &pAdoRecordBinding);
BOOL AddNew(CADORecordBinding &pAdoRecordBinding);
// 記錄集導航操作
public:
BOOL MoveFirst();
BOOL MovePrevious();
BOOL MoveNext();
BOOL MoveLast();
BOOL Move(long lRecords, _variant_t Start = _variant_t((long)adBookmarkFirst));
// 查找指定的記錄
BOOL Find(LPCTSTR lpszFind, SearchDirectionEnum SearchDirection = adSearchForward);
BOOL FindNext();
// 查詢
public:
BOOL Open(LPCTSTR strSQL, long lOption = adCmdText, CursorTypeEnum CursorType = adOpenStatic, LockTypeEnum LockType = adLockOptimistic);
BOOL Cancel();
void Close();
public:
//存如字段
BOOL PutCollect(long index, const _variant_t &value);
BOOL PutCollect(long index, const CString &value);
BOOL PutCollect(long index, const double &value);
BOOL PutCollect(long index, const float &value);
BOOL PutCollect(long index, const long &value);
BOOL PutCollect(long index, const DWORD &value);
BOOL PutCollect(long index, const int &value);
BOOL PutCollect(long index, const short &value);
BOOL PutCollect(long index, const BYTE &value);
BOOL PutCollect(long index, const bool &value);
BOOL PutCollect(long index, const COleDateTime &value);
BOOL PutCollect(long index, const COleCurrency &value);
BOOL PutCollect(LPCTSTR strFieldName, const _variant_t &value);
BOOL PutCollect(LPCTSTR strFieldName, const CString &value);
BOOL PutCollect(LPCTSTR strFieldName, const double &value);
BOOL PutCollect(LPCTSTR strFieldName, const float &value);
BOOL PutCollect(LPCTSTR strFieldName, const long &value);
BOOL PutCollect(LPCTSTR strFieldName, const DWORD &value);
BOOL PutCollect(LPCTSTR strFieldName, const int &value);
BOOL PutCollect(LPCTSTR strFieldName, const short &value);
BOOL PutCollect(LPCTSTR strFieldName, const BYTE &value);
BOOL PutCollect(LPCTSTR strFieldName, const bool &value);
BOOL PutCollect(LPCTSTR strFieldName, const COleDateTime &value);
BOOL PutCollect(LPCTSTR strFieldName, const COleCurrency &value);
//取得字段
BOOL GetCollect(long index, CString &value);
BOOL GetCollect(long index, double &value);
BOOL GetCollect(long index, float &value);
BOOL GetCollect(long index, long &value);
BOOL GetCollect(long index, DWORD &value);
BOOL GetCollect(long index, int &value);
BOOL GetCollect(long index, short &value);
BOOL GetCollect(long index, BYTE &value);
BOOL GetCollect(long index, bool &value);
BOOL GetCollect(long index, COleDateTime &value);
BOOL GetCollect(long index, COleCurrency &value);
BOOL GetCollect(LPCSTR strFieldName, CString &strValue);
BOOL GetCollect(LPCSTR strFieldName, double &value);
BOOL GetCollect(LPCSTR strFieldName, float &value);
BOOL GetCollect(LPCSTR strFieldName, long &value);
BOOL GetCollect(LPCSTR strFieldName, DWORD &value);
BOOL GetCollect(LPCSTR strFieldName, int &value);
BOOL GetCollect(LPCSTR strFieldName, short &value);
BOOL GetCollect(LPCSTR strFieldName, BYTE &value);
BOOL GetCollect(LPCSTR strFieldName, bool &value);
BOOL GetCollect(LPCSTR strFieldName, COleDateTime &value);
BOOL GetCollect(LPCSTR strFieldName, COleCurrency &value);
// BLOB 數據存取 (image)
BOOL AppendChunk(FieldPtr pField, LPVOID lpData, UINT nBytes);
BOOL AppendChunk(long index, LPVOID lpData, UINT nBytes);
BOOL AppendChunk(LPCSTR strFieldName, LPVOID lpData, UINT nBytes);
BOOL AppendChunk(long index, LPCTSTR lpszFileName);
BOOL AppendChunk(LPCSTR strFieldName, LPCTSTR lpszFileName);
BOOL GetChunk(FieldPtr pField, LPVOID lpData);
BOOL GetChunk(long index, LPVOID lpData);
BOOL GetChunk(LPCSTR strFieldName, LPVOID lpData);
BOOL GetChunk(long index, CBitmap &bitmap);
BOOL GetChunk(LPCSTR strFieldName, CBitmap &bitmap);
public:
// 過濾記錄 ---------------------------------
BOOL SetFilter(LPCTSTR lpszFilter);
// 排序 -------------------------------------
BOOL SetSort(LPCTSTR lpszCriteria);
// 測試是否支持某方法 -----------------------
BOOL Supports(CursorOptionEnum CursorOptions = adAddNew);
// 克隆 -------------------------------------
BOOL Clone(CAdoRecordSet &pRecordSet);
_RecordsetPtr operator = (_RecordsetPtr &pRecordSet);
// 格式化 _variant_t 類型值 -----------------
//成員變量 --------------------------------------------
protected:
CString m_errormessage;
CAdoConnection *m_pConnection;
_RecordsetPtr m_pRecordset;
CString m_strSQL;
CString m_strFind;
CString m_strFileName;
IADORecordBinding *m_pAdoRecordBinding;
SearchDirectionEnum m_SearchDirection;
public:
_variant_t m_varBookmark;
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -