ADO wrapper

LiuYinChina LiuYinChina 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

/********************************************************************
Created: 2007/03/30
Created: 30:3:2007 13:06
Author: 刘胤

Purpose: wrapper for _Recordset
*********************************************************************/

#ifndef AdoRecordSet_H
#define AdoRecordSet_H

#include <AfxDisp.h>
#include <icrsint.h>

#pragma warning(disable:4146)
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "adoEOF"), rename("BOF", "adoBOF")
#pragma warning(default:4146)

namespace AdoUtility
{
class CAdoConnection;

class CAdoRecordSet
{
public:
CAdoRecordSet(BOOL bInit = TRUE);
~CAdoRecordSet();

void Attach(_Recordset *pRecordset);
_Recordset * Detach();

BOOL SetIndex(const CString &strIndex) const;
BOOL GetIndex(CString &strIndex) const;

BOOL Resync(AffectEnum AffectRecords, ResyncEnum ResyncValues) const;

BOOL GetDataMember(CString &strDataMember) const;
BOOL SetDataMember(const CString &strDataMember) const;

BOOL SetStayInSync(BOOL bStayInSync) const;
BOOL GetStayInSync(BOOL &bStayInSync) const;

BOOL GetActiveCommand(IDispatch **ppCmd) const;

BOOL Find(const CString &strFind, long nSkipRecords, SearchDirectionEnum nSearchDirection) const;

BOOL GetMarshalOptions(MarshalOptionsEnum &nMarshalOptions) const;
BOOL SetMarshalOptions(MarshalOptionsEnum nMarshalOptions) const;

BOOL GetSupports(CursorOptionEnum CursorOptions, VARIANT_BOOL &bSupports) const;

BOOL UpdateBatch(AffectEnum AffectRecords) const;
BOOL CancelBatch(AffectEnum AffectRecords) const;

CAdoRecordSet * Clone(LockTypeEnum nLockType) const;
CAdoRecordSet * xClone() const;

BOOL GetPageSize(long &nPageSize) const;
BOOL SetPageSize(long nPageSize) const;

BOOL GetSort(CString &strSort) const;
BOOL SetSort(const CString &strSort) const;

BOOL GetPageCount(long &nPageCount) const;

BOOL xResync(AffectEnum AffectRecords) const;

BOOL Requery(long nOptions) const;

BOOL GetAbsolutePage(PositionEnum &nPosition) const;
BOOL SetAbsolutePage(PositionEnum nPosition) const;

BOOL SetSource(const CString &strSource) const;
BOOL GetSource(CString &strSource) const;

BOOL GetLockType(LockTypeEnum &nLockType) const;
BOOL SetLockType(LockTypeEnum nLockType) const;

BOOL GetCacheSize(long &nCacheSize) const;
BOOL SetCacheSize(long nCacheSize) const;

BOOL GetBookmark(BookmarkEnum &bookmark) const;
BOOL SetBookmark(BookmarkEnum bookmark = adBookmarkFirst) const;

BOOL SetAbsolutePosition(PositionEnum nPosition) const;
BOOL GetAbsolutePosition(PositionEnum &nPosition) const;

BOOL GetCursorLocation(CursorLocationEnum &nCursorLocation) const;
BOOL SetCursorLocation(CursorLocationEnum nCursorLocation = adUseClient) const;

BOOL GetCursorType(CursorTypeEnum &nCursorType) const;
BOOL SetCursorType(CursorTypeEnum nCursorType = adOpenStatic) const;

BOOL GetState(long &nState) const;
BOOL GetStatus(long &nStatus) const;

BOOL GetFieldAttributes(long nIndex, long &nAttributes) const;
BOOL GetFieldAttributes(LPCTSTR pszFieldName, long &nAttributes) const;

BOOL GetFieldType(long nIndex, DataTypeEnum &nDataType) const;
BOOL GetFieldType(LPCTSTR pszFieldName, DataTypeEnum &nDataType) const;

CAdoConnection * GetConnection() const;
BOOL SetAdoConnection(CAdoConnection * const pConnection) const;

BOOL GetEditMode(EditModeEnum &nEditMode) const;

BOOL Open(const CString &strSQL, long nOption = adCmdText, CursorTypeEnum nCursorType = adOpenStatic, LockTypeEnum nLockType = adLockOptimistic) const;
BOOL Cancel() const;
BOOL Close() const;

BOOL IsOpen() const;
BOOL IsBOF(BOOL &bBOF) const;
BOOL IsEOF(BOOL &bEOF) const;

BOOL GetRecordCount(long &nRecordCount) const;
BOOL GetFieldsCount(long &nFieldsCount) const;

BOOL GetMaxRecordCount(long &nMaxRecordCount) const;
BOOL SetMaxRecordCount(long nMaxRecordCount) const;

BOOL MoveFirst() const;
BOOL MoveNext() const;
BOOL MovePrevious() const;
BOOL MoveLast() const;
BOOL Move(long nRecords, const CComVariant &varStartPos = CComVariant((long) adBookmarkFirst)) const;

BOOL GetFieldName(long nIndex, CString &strFieldName) const;

public:
BOOL AddNew() const;
BOOL Update() const;
BOOL CancelUpdate() const;
BOOL Delete(AffectEnum AffectRecords = adAffectCurrent) const;

BOOL GetCollect(long nIndex, bool &bValue) const;
BOOL GetCollect(long nIndex, CString &strValue) const;
BOOL GetCollect(long nIndex, double &dValue) const;
BOOL GetCollect(long nIndex, float &dValue) const;
BOOL GetCollect(long nIndex, long &nValue) const;
BOOL GetCollect(long nIndex, DWORD &dwValue) const;
BOOL GetCollect(long nIndex, int &nValue) const;
BOOL GetCollect(long nIndex, short &nValue) const;
BOOL GetCollect(long nIndex, BYTE &nValue) const;
BOOL GetCollect(long nIndex, COleDateTime &oleValue) const;
BOOL GetCollect(long nIndex, COleCurrency &oleValue) const;

BOOL GetCollect(LPCSTR pszFieldName, bool &bValue) const;
BOOL GetCollect(LPCSTR pszFieldName, CString &strValue) const;
BOOL GetCollect(LPCSTR pszFieldName, double &dValue) const;
BOOL GetCollect(LPCSTR pszFieldName, float &dValue) const;
BOOL GetCollect(LPCSTR pszFieldName, long &nValue) const;
BOOL GetCollect(LPCSTR pszFieldName, DWORD &dwValue) const;
BOOL GetCollect(LPCSTR pszFieldName, int &nValue) const;
BOOL GetCollect(LPCSTR pszFieldName, short &nValue) const;
BOOL GetCollect(LPCSTR pszFieldName, BYTE &nValue) const;
BOOL GetCollect(LPCSTR pszFieldName, COleDateTime &value) const;
BOOL GetCollect(LPCSTR pszFieldName, COleCurrency &value) const;

public:
BOOL PutCollect(long nIndex, LPCTSTR pszValue) const;
BOOL PutCollect(long nIndex, const double &dValue) const;
BOOL PutCollect(long nIndex, const float &dValue) const;
BOOL PutCollect(long nIndex, long nValue) const;
BOOL PutCollect(long nIndex, DWORD nValue) const;
BOOL PutCollect(long nIndex, int nValue) const;
BOOL PutCollect(long nIndex, short nValue) const;
BOOL PutCollect(long nIndex, BYTE nValue) const;
BOOL PutCollect(long nIndex, bool bValue) const;
BOOL PutCollect(long nIndex, const COleDateTime &oleValue) const;
BOOL PutCollect(long nIndex, const COleCurrency &oleValue) const;

BOOL PutCollect(LPCTSTR pszFieldName, LPCTSTR pszValue) const;
BOOL PutCollect(LPCTSTR pszFieldName, const double &dValue) const;
BOOL PutCollect(LPCTSTR pszFieldName, const float &dValue) const;
BOOL PutCollect(LPCTSTR pszFieldName, long nValue) const;
BOOL PutCollect(LPCTSTR pszFieldName, DWORD nValue) const;
BOOL PutCollect(LPCTSTR pszFieldName, int nValue) const;
BOOL PutCollect(LPCTSTR pszFieldName, short nValue) const;
BOOL PutCollect(LPCTSTR pszFieldName, BYTE nValue) const;
BOOL PutCollect(LPCTSTR pszFieldName, bool bValue) const;
BOOL PutCollect(LPCTSTR pszFieldName, const COleDateTime &oleValue) const;
BOOL PutCollect(LPCTSTR pszFieldName, const COleCurrency &oleValue) const;
...全文
评论 6
收藏 已收藏
分享
返回顶部
LiuYinChina
数据库 4,017 成员 39,805 内容