- #ifndef _ADO_DATASET_H
- #define _ADO_DATASET_H
- /********************************************************
- * Class Name : CADODataSet. *
- * Purpose : ADO Dataset Components' Base Class. *
- * File Name : ADODataSet.h / ADODataSet.cpp. *
- *------------------------------------------------------*
- * Author : Devia Lee. Date: 2004-04-01 *
- ********************************************************/
- #include <io.h>
- #include ".Variantex.h"
- #include ".ADOObject.h"
- #include ".ADOConnection.h"
- class CFields;
- class CADODataSet : public CADOObject
- {
- public:
- CADODataSet();
- CADODataSet(_RecordsetPtr pRecordset);
- virtual ~CADODataSet();
- //-------------------------------------------------
- //Set / Get the dataset's connection object.
- void SetConnection(CADOConnection &pADOConnection);
- CADOConnection &GetConnection();
- //Open or close the dataset.
- bool Open(LPCSTR lpszSQLText);
- bool Close();
- //-------------------------------------------------
- //get the dataset's state.
- bool IsOpened();
- //determine the dataset cursor whether or not
- //arrival the begin(end) of the dataset.
- bool IsBof();
- bool IsEof();
- //determine the dataset whether is empty.
- bool IsEmpty();
- //Cursor Location.
- void Prior();
- void Next();
- void First(); //move the cursor to the begin.
- void Last(); //move the cursor to the end.
- //Get the dataset's informations.
- LONG GetRecordCounts();
- //-------------------------------------------------
- //Get the dataset's fields object.
- CFields Fields();
- //-------------------------------------------------
- //Get the dataset edit mode.
- EditModeEnum GetEditMode();
- //Insert / Edit / Delete / Update.
- void Edit();
- void Insert();
- void Delete();
- void Update();
- //Storage COM support
- bool SaveToXMLFile(LPCSTR szfile);
- bool SaveToXMLStream(_StreamPtr &pstream);
- bool SaveToBuffer(char **buffer, LONG &size);
- //Load from XML file or Stream object.
- bool LoadFromXMLFile(LPCSTR szfile);
- bool LoadFromXMLStream(_StreamPtr &pstream);
- private:
- //ADO database connection object.
- CADOConnection* m_pADOConnection;
- //Record set smart pointer
- _RecordsetPtr m_pRecordset;
- //Dataset's SQL text.
- string m_sSQLText;
- };
- /********************************************************
- * Class Name : CField. *
- * Purpose : Dataset Field SubAggregate Class; *
- * FieldPtr encapsulation class. *
- * File Name : ADODataSet.h / ADODataSet.cpp. *
- *------------------------------------------------------*
- * Author : Devia Lee. Date: 2004-04-02 *
- ********************************************************/
- class CField
- {
- public:
- //constructor or destructor procedure
- CField();
- CField(FieldPtr &fldPtr);
- virtual ~CField();
- //get fieldPtr smart pointer
- FieldPtr getSmartPtr();
- //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- CField& operator=(CField &fldObj);
- CField& operator=(FieldPtr fldPtr);
- //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- //get the field type
- DataTypeEnum getType();
- //get the field define size
- long getDefineSize();
- //get the field actual size
- long getActualSize();
- //get the field name
- string getName();
- //get the field value.
- CVariantEx getValue();
- //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- //set the field value.
- void setValue(CVariantEx var);
- //determine the field whether is null
- bool IsNull();
- protected:
- //field smart pointer
- FieldPtr m_spField;
- };
- /********************************************************
- * Class Name : CBlobField. *
- * Purpose : Dataset Blob Field SubAggregate Class;*
- * File Name : ADODataSet.h / ADODataSet.cpp. *
- *------------------------------------------------------*
- * Author : Devia Lee. Date: 2004-04-03 *
- ********************************************************/
- class CBlobField : public CField
- {
- public:
- CBlobField(CField &oField);
- virtual ~CBlobField();
- //Load contents from stream / file.
- void LoadFromStream( const char *lpBuffer,
- const ULONG vBufSize);
- void LoadFromFile(LPCSTR lpszFileName);
- //Save current contents to stream / file.
- long SaveToStream( char *lpBuffer,
- const ULONG vMaxBufSize);
- long SaveToFile(LPCSTR lpszFileName);
- };
- /********************************************************
- * Class Name : CFields. *
- * Purpose : Dataset Field Aggregate Class; *
- * FieldsPtr encapsulation class. *
- * File Name : ADODataSet.h / ADODataSet.cpp. *
- *------------------------------------------------------*
- * Author : Devia Lee. Date: 2004-04-02 *
- ********************************************************/
- class CFields
- {
- public:
- //constructor and destructor procedure
- CFields();
- CFields(FieldsPtr fldsPtr);
- virtual ~CFields();
- //Get fieldPtr smart pointer
- FieldsPtr &getSmartPtr();
- //Get the subfields count.
- const long FieldCount();
- //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- CFields &operator=(CFields &fldsObj);
- CFields &operator=(FieldsPtr &fldsPtr);
- CField operator[](long i);
- //
- CField FieldByName(LPCSTR lpszFieldName);
- protected:
- //fields smart pointer
- FieldsPtr m_spFileds;
- };
- #endif //_ADO_DATASET_H