12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- /*************************************************************
- /* Copyright (C), 2014-2020, lyfz. Co., Ltd.
- /* 文件名: **.h
- /* 作者: Jeff.w
- /* 创建日期: 2014-08-16
- /* 版本号: V1.0
- /* 描述: 核心层底,数据库ADO编程
- /* 其它:
- /* 主要类模块:
- /* 历史修改记录:
- /* 作者 时间 版本 描述
- /* Jeff.w 14/08/16 1.0 创建这个模块
- ***************************************************************/
- #ifndef __ADO_COMMAND_HEADER__
- #define __ADO_COMMAND_HEADER__
- #pragma once
- #include "AdoDef.h"
- #include "ADODatabase.h"
- #include "ADOParameter.h"
- class CADOCommand
- {
- public:
- enum cadoCommandType
- {
- typeCmdText = adCmdText,
- typeCmdTable = adCmdTable,
- typeCmdTableDirect = adCmdTableDirect,
- typeCmdStoredProc = adCmdStoredProc,
- typeCmdUnknown = adCmdUnknown,
- typeCmdFile = adCmdFile
- };
- CADOCommand(CADODatabase* pAdoDatabase, CString strCommandText = _T(""), int nCommandType = typeCmdStoredProc);
- virtual ~CADOCommand()
- {
- ::SysFreeString(m_pCommand->CommandText);
- m_pCommand.Release();
- m_pCommand = NULL;
- m_strCommandText = _T("");
- }
- void SetTimeout(long nTimeOut){m_pCommand->PutCommandTimeout(nTimeOut);};
- void SetText(CString strCommandText);
- void SetType(int nCommandType);
- BOOL AddParameter(CADOParameter* pAdoParameter);
- BOOL AddParameter(CString strName, int nType, int nDirection, long lSize, int nValue);
- BOOL AddParameter(CString strName, int nType, int nDirection, long lSize, long lValue);
- BOOL AddParameter(CString strName, int nType, int nDirection, long lSize, double dblValue, int nPrecision = 0, int nScale = 0);
- BOOL AddParameter(CString strName, int nType, int nDirection, long lSize, CString strValue);
- BOOL AddParameter(CString strName, int nType, int nDirection, long lSize, COleDateTime time);
- BOOL AddParameter(CString strName, int nType, int nDirection, long lSize, _variant_t vtValue, int nPrecision = 0, int nScale = 0);
- // inline func;
- inline int GetType(){return m_nCommandType;};
- inline CString GetText(){return m_strCommandText;};
- BOOL Execute(int nCommandType = typeCmdStoredProc);
- int GetRecordsAffected(){return m_nRecordsAffected;};
- inline _CommandPtr GetCommand(){return m_pCommand;};
- protected:
- void dump_com_error(_com_error &e);
- protected:
- _CommandPtr m_pCommand;
- int m_nCommandType;
- int m_nRecordsAffected;
- CString m_strCommandText;
- CString m_strLastError;
- DWORD m_dwLastError;
- };
- #endif
|