| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- /*************************************************************************
- 【文件名】 DBCtrl.h
- 【功能模块和目的】 数据库模块导出类头文件
- 【开发者及日期】 郑石诺 2015/01/08
- 【版本】 V1.0.0
- 【版权信息】 Copyright (C)2015 河南华谊网络科技有限公司
- 【更改记录】
- *************************************************************************/
- #pragma once
- #ifdef DBCTRL_EXPORTS
- #define DBCTRL_API __declspec(dllexport)
- #else
- #define DBCTRL_API __declspec(dllimport)
- #endif
- #define OTL_MAX_BUFF_SIZE 1024 // 字符串缓冲区最大长度
- #define OTL_MAX_TEXT_SIZE 4096 // TEXT缓冲区最大长度
- #define OTL_REG_KEY_SIZE 256 // 注册表键值最大长度
- // 数据库类型
- typedef enum tagDB_TYPE
- {
- DB_SQLServer = 0,
- DB_MySQL = 1,
- DB_Oracle = 2,
- DB_Error = 3
- } DB_TYPE;
- /*************************************************************************
- 【类名】 IOtlRecordset
- 【功能】 OTL连接控制记录集接口
- 【接口说明】
- 【开发者及日期】 郑石诺 2015/01/08
- 【版本】 V1.0.0
- 【版权信息】 Copyright (C)2015 河南华谊网络科技有限公司
- 【更改记录】
- *************************************************************************/
- class DBCTRL_API IOtlRecordset
- {
- public:
- virtual ~IOtlRecordset(void) = 0 {}
- static void DestroyInstance(IOtlRecordset* pRecord);
- // 数据控制
- virtual BOOL IsEOF(void) = 0; // 是否已遍历到记录保结尾
- virtual BOOL MoveNextRow(void) = 0; // 移动记录集到下一行
- virtual BOOL GetValueInt(char *pColName, int &nValue) = 0; // 获取当前行指定字段值 整形
- virtual BOOL GetValueStr(char *pColName, char *pValue) = 0; // 获取当前行指定字段值 字符串
- virtual BOOL GetValueText(char *pColName, char *pValue) = 0; // 获取当前行指定字段值 较大文本值
- virtual BOOL GetValueFloat(char *pColName, float &Value) = 0; // 获取当前行指定字段值 浮点
- virtual int GetValueIntByIndex(int index) = 0; // 通过字段ID获取整型记录
- virtual int GetValueInt(CString FieldName) = 0; // 通过字段名称获取整型记录
- virtual CString GetValueStrByIndex(int index) = 0; // 通过字段ID获取字符串记录
- virtual CString GetValueStr(CString FieldName) = 0; // 通过字段名称获取字符串记录
- virtual BOOL GetValueFloatByIndex(int index, float &Value) = 0; // 通过字段ID获取浮点记录
- // 错误处理
- virtual LPCTSTR GetLastError(void) = 0;
- };
- /*************************************************************************
- 【类名】 IOtlStoredProc
- 【功能】 存储过程执行实体(仅供需返回值的存储过程或存储函数)
- 【接口说明】
- 【开发者及日期】 郑石诺 2015/01/08
- 【版本】 V1.0.0
- 【版权信息】 Copyright (C)2015 河南华谊网络科技有限公司
- 【更改记录】
- *************************************************************************/
- class DBCTRL_API IOtlStoredProc
- {
- public:
- virtual ~IOtlStoredProc(void) = 0 {}
- static void DestroyInstance(IOtlStoredProc* a_pProc);
- // 添加存储过程输入参数(目前仅实现了两种重载,后续根据需要可自行添加)
- virtual BOOL Input(LPCTSTR a_StrParam) = 0;
- virtual BOOL Input(UINT a_UintParam) = 0;
- virtual BOOL Input(int a_IntParam) = 0;
- // 存储过程执行完毕输出参数(目前仅实现了两种重载,后续根据需要可自行添加)
- virtual BOOL Output(UINT& a_UintReturn) = 0;
- virtual BOOL Output(int& a_IntParam) = 0;
- virtual BOOL Output(LPTSTR a_StrParam) = 0;
- virtual BOOL Output(float a_FloatParam) = 0;
- // 错误处理
- virtual LPCTSTR GetLastError(void) = 0;
- };
- /*************************************************************************
- 【类名】 IOtlConnection
- 【功能】 OTL连接控制接口
- 【接口说明】
- 【开发者及日期】 郑石诺 2015/01/08
- 【版本】 V1.0.0
- 【版权信息】 Copyright (C)2015 河南华谊网络科技有限公司
- 【更改记录】
- *************************************************************************/
- class DBCTRL_API IOtlConnection
- {
- public:
- virtual ~IOtlConnection(void) = 0 {}
- static IOtlConnection* getInstance(void);
- static void Initialize(void);
- // 数据库连接控制
- virtual BOOL Connect() = 0; // 连接数据库(注册表中默认配置的数据库)
- virtual BOOL Connect(LPCTSTR lpszConnString) = 0; // 连接指定数据库
- virtual BOOL ConnectTest(LPCTSTR lpszConnString, LPSTR lpErrInfo) = 0; // 连接测试
- virtual void Disconnect() = 0; // 断开连接
- virtual DB_TYPE GetDatabaseType() = 0; // 获取数据库类型
- // 数据操作
- virtual BOOL ExecCommand(LPCTSTR lpszSQL) = 0; // 直接命令执行
- virtual void DropTableCommand(LPCTSTR lpszSQL) = 0; // 删除表命令函数
- virtual BOOL InsertConstant(LPCTSTR lpszSQL) = 0; // 恒量插入(单数据)
- virtual BOOL GetSingleDataString(LPCTSTR lpszSQL, CHAR* lpValue) = 0; // 获取字符串单值
- virtual BOOL GetSingleDataText(LPCTSTR lpszSQL, CHAR* lpValue) = 0; // 获取Text串单值
- virtual BOOL GetSingleDataInt(LPCTSTR lpszSQL, LONG& nValue) = 0; // 获取整型单值
- virtual long GetSingleDataInt(LPCTSTR strSql) = 0; // 获取整型单值
- virtual CString GetSingleDataStr(LPCTSTR strSql) = 0; // 获取字符串单值
- virtual long GetSingleDataStr2Int(LPCTSTR strSql) = 0; // 获取字符串单值并转化成整型返回
- virtual IOtlRecordset* QueryRecords(LPCTSTR lpszSQL) = 0; // 查询记录集
- virtual IOtlStoredProc* CallStoredProc(const CString& a_DeclareWord) = 0; // 调用存储过程
- // 错误处理
- virtual LPCTSTR GetLastError() = 0;
- };
|