1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- /*************************************************************
- /* Copyright (C), 2014-2020, lyfz. Co., Ltd.
- /* 文件名: AdoImpl.h
- /* 作者: Jeff.w
- /* 创建日期: 2014-08-16
- /* 版本号: V1.0
- /* 描述: 核心层底,数据库ADO编程
- /* 其它:
- /* 主要类模块:
- /* 历史修改记录:
- /* 作者 时间 版本 描述
- /* Jeff.w 14/08/18 1.0 创建这个模块
- ***************************************************************/
- #ifndef __ADO_IMPL_HEADER__
- #define __ADO_IMPL_HEADER__
- #pragma once
- #include "AdoDef.h"
- #include "ADODatabase.h"
- #include "ADORecordset.h"
- #include "ADOCommand.h"
- // 声明回调函数;
- typedef int (CALLBACK *RecordsetCallback)(IN const DWORD& dwCallBackType, IN LPVOID lpParamter, IN const int& nRecordCount, IN CADORecordset* pRet);
- // Jeff.一个数据库只有一个AdoImpl实例;
- // 该类使用线程,监测线程的作用是判断数据库是否断开并重连;
- // 未对二进制文件支持操作;
- class AdoImpl
- {
- CString m_strQuery;
- CString m_strLastError;
- DWORD m_dwLastError;
- inline CString GetQuery() {return m_strQuery;};
- inline void SetQuery(LPCSTR strQuery) {m_strQuery = strQuery;};
- private:
- CRITICAL_SECTION m_csAdo;
- TCHAR m_szConnectString[1024];// 暂使用1024魔数,后期升级再定义;
- CADODatabase *m_pADODatabase;
- BOOL OpenADORecordSet(IN CADORecordset *pRSet, IN LPCTSTR lpSQL, IN const int& nCursorLocation = adUseClient);
- void CloseADORecordSet(IN CADORecordset* pRSet);
- void DeleteADORecordSet(IN CADORecordset* pRSet);
- public:
- AdoImpl(void);
- virtual ~AdoImpl(void);
- void SetConnectString(
- IN const int &nType,
- IN LPCTSTR lpDataSource,
- IN LPCTSTR lpDatabaseTCPPort,
- IN LPCTSTR lpDatabaseAccount,
- IN LPCTSTR lpDatabasePassWord,
- IN LPCTSTR lpDatabaseName,
- IN LPCTSTR lpDatabaseFile = NULL);
- BOOL IsOpen();
- BOOL Opendatabase(IN LPCTSTR lpConnectString = NULL);
- void Closedatabase();
- int Execute(IN LPCTSTR lpSQL);//不返回记录集;
- bool GetADODateBaseStatus();
- CADODatabase *GetAdoDatabase(){return m_pADODatabase;};
- // 应用层接口;
- public:
- DWORD GetTableRecordCount(IN LPCTSTR lpTableName, IN LPCTSTR lpFilters); // 返回要查询的表的记录数;
- // 使用回调函数来处理具体的数据;
- int GetFieldValueList(IN LPCTSTR lpTableName, IN LPCTSTR lpFields, IN LPCTSTR lpFilters, IN const DWORD &dwCallBackType,IN LPVOID lpCallBack, IN OUT LPVOID lpParamter);
- int GetFieldValueListEx(IN LPCTSTR lpTableName, IN LPCTSTR lpFields, IN LPCTSTR lpFilters, IN const DWORD &dwCallBackType,IN LPVOID lpCallBack, IN OUT LPVOID lpParamter);
- BOOL AppenChunkFromFile(IN LPCTSTR lpTableName, IN LPCTSTR lpFieldName, IN LPCTSTR lpFileName);
- BOOL AppenChunkFromBuffer(IN LPCTSTR lpTableName, IN LPCTSTR lpFieldName, IN BYTE* lpBuffer, IN const int& nBuflen);
- };
- #endif
|