ADOConnection.h
上传用户:maryhy001
上传日期:2007-05-02
资源大小:2317k
文件大小:2k
- #ifndef _ADO_CONNECTION_H
- #define _ADO_CONNECTION_H
- /********************************************************
- * Class Name : CADOConnection. *
- * Purpose : ADO's Database Connection Class. *
- * File Name : ADOConnection.h / ADOConnection.cpp *
- *------------------------------------------------------*
- * Author : Devia Lee. Date: 2004-04-01 *
- ********************************************************/
- #include ".ADOObject.h"
- #include ".ADOException.h"
- class CADOConnection : public CADOObject
- {
- public:
- CADOConnection();
- virtual ~CADOConnection();
- //create the connection.
- bool Create(LPCSTR lpszConnect,
- ConnectModeEnum cmMode = ADOCG::adModeUnknown,
- CursorLocationEnum clCursorLocation = ADOCG::adUseClient,
- int nConnectionTimeOut = 5);
-
- //destroy the connection.
- void Destroy();
- //get the connection whether is opened.
- bool IsActived();
- //get the connection string.
- LPCSTR GetConnectionString(void);
- //Transaction processing.
- bool BeginTransaction();
- bool CommitTransaction();
- bool RollBackTransaction();
- //Execute some sql statements.
- _RecordsetPtr Execute(LPCSTR lpszSQLText, CommandTypeEnum ctCmdType = adCmdText);
- //open schema.
- _RecordsetPtr OpenSchema(SchemaEnum Schema = adSchemaTables);
- public:
- //Initialize or UnInitialize the ADO connection.
- static bool ADO_Initialize();
- static void ADO_UnInitialize();
- //get the connection smart ptr.
- _ConnectionPtr getConnectionPtr();
- private:
- //flag the connection is OK.
- bool m_bConnected;
- //db connection smart pointer
- _ConnectionPtr m_pConnection;
- //db connection string text.
- string m_sConnectionString;
- };
- #endif //_ADO_CONNECTION_H