SQLite3Interface.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef __SQLITE3INTERFACE_H_
  2. #define __SQLITE3INTERFACE_H_
  3. /************************************************************************/
  4. /*
  5. 类名: CSQLiter3Interface
  6. 描述: sqlite3数据库操作
  7. */
  8. /************************************************************************/
  9. #include <string>
  10. #ifndef _UNICODE
  11. typedef std::string TString;
  12. #else
  13. typedef wstring TString;
  14. #endif
  15. struct sqlite3;
  16. // 创建表,注意:SQLite3每条SQL语句结束时需要加上分号;
  17. #define CREATE_DB_TBL_ "create table remoteinfo(\
  18. [domain] text not null,\
  19. [shopname] text not null,\
  20. [ipaddr] text not null,\
  21. [pcname] text not null,\
  22. [sharedir] text not null,\
  23. PRIMARY KEY([domain]));"
  24. //////////////////////////////////////////////////////////////////////////
  25. // 唯一的应用程序对象
  26. typedef struct _STRemoteInfo_
  27. {
  28. int bInUse;
  29. TCHAR szBranch[MAX_PATH];
  30. TCHAR szIP[MAX_PATH];
  31. TCHAR szDoMain[MAX_PATH];
  32. }STRemoteInfo,*pSTRemoteInfo;
  33. class CSQLiter3Interface
  34. {
  35. public:
  36. CSQLiter3Interface();
  37. ~CSQLiter3Interface();
  38. //打开
  39. int OpenSQLite3DB(const char* pDBPath);
  40. //创建表
  41. int CreateTabel(const char* pSql, CString& strError);
  42. //执行
  43. int Exec(const char* pSql, CString& strError);
  44. //错误消息
  45. const char* Get_ErrMsg();
  46. //查询
  47. int Select(const char* pTableName, const char* pFields, const char* pLimit, std::vector<TString>& vValues, CString& strError);
  48. //插入
  49. int Insert(const char* pTableName, const char* pFields, const char* pValues, CString& strError);
  50. //删除
  51. int Delete(const char* pTableName, const char* pLimit, CString& strError);
  52. //关闭
  53. int Close();
  54. private:
  55. sqlite3* m_pSqli3db;
  56. };
  57. #endif