1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#define CATCHERROR(ptr,a) catch(_com_error &e)\
{\
ErrorHandler(e,m_ErrStr);\
ptr=NULL;\
return a;\
}
#define CATCHERRGET catch(_com_error &e)\
{\
ErrorHandler(e,m_ErrStr);\
sprintf(m_ErrStr,"%s\n**For Field Name:%s",m_ErrStr,FieldName);\
return 0;\
}
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" \
rename("EOF", "EndOfFile")
typedef ADODB::_RecordsetPtr RecPtr;
typedef ADODB::_ConnectionPtr CnnPtr;
class Database;
class Table;
class Database
{
public:
CnnPtr m_Cnn;
char m_ErrStr[500];
Database();
bool Open(char* UserName, char* Pwd,char* CnnStr);
bool Close();
bool OpenTbl(int Mode, char* CmdStr, Table& Tbl);
bool Execute(const char* CmdStr);
bool Execute(const char* CmdStr, Table& Tbl);
void GetErrorErrStr(char* ErrStr);
};
class Table{
public:
RecPtr m_Rec;
char m_ErrStr[500];
Table();
void GetErrorErrStr(char* ErrStr);
int ISEOF();
HRESULT MoveNext();
HRESULT MovePrevious();
HRESULT MoveFirst();
HRESULT MoveLast();
int AddNew();
int Update();
int Add(char* FieldName, char* FieldValue);
int Add(char* FieldName,int FieldValue);
int Add(char* FieldName,float FieldValue);
int Add(char* FieldName,double FieldValue);
int Add(char* FieldName,long FieldValue);
bool Get(char* FieldName, char* FieldValue);
bool Get(char* FieldName, std::string& FieldValue);
int GetInt(char* FieldName);
bool Get(char* FieldName,float& FieldValue);
bool Get(char* FieldName,double& FieldValue);
bool Get(char* FieldName,double& FieldValue,int Scale);
bool Get(char* FieldName,long& FieldValue);
};
|