//DbAccess.h #ifndef DbAccess_h #define DbAccess_n #include //this path may need to be changed on your machine: #import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile") class DbAccess { public: DbAccess(const char *conStr): m_strConn(conStr), m_boolHasError(false), m_pConnection(NULL){}; _RecordsetPtr Execute(_bstr_t strSQL); std::string PrintProviderError(_ConnectionPtr pConnection, const char *strSQL); std::string PrintComError(_com_error &e); void Close(); bool HasError(){return m_boolHasError;}; std::string GetLastError(){return m_strErr;}; private: std::string m_strErr, m_strConn; bool m_boolHasError; _ConnectionPtr m_pConnection; }; class Utils{ public: enum STRTYPES{ enuSignedDecimal = 0, enuUnSignedDecimal, enuOctal, enuHex }; static std::string IntToString(long value, enum STRTYPES type = enuSignedDecimal){ char buffer[64]; switch (type){ case enuSignedDecimal : sprintf(buffer, "%ld", value); break; case enuUnSignedDecimal : sprintf(buffer, "%lu", value); break; case enuOctal : sprintf(buffer, "%lo", value); break; case enuHex : sprintf(buffer, "%lx", value); break; default : sprintf(buffer, "%ld", value); break; } return buffer; }; }; #endif