HtlMsql.h 729 B

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #pragma comment(lib,"libmysql")
  3. #include <mysql.h>
  4. typedef struct DatabaseInformation //数据库信息
  5. {
  6. const char* server_address;///服务器地址
  7. const char* user_name;//数据管理员
  8. const char* password;//管理员密码
  9. const char* database_name;//数据库名称
  10. int server_port;//端口
  11. }DBINFO;
  12. class HtlMysql
  13. {
  14. private:
  15. //PreparedStatement* pstmt;
  16. MYSQL* p_sql = NULL;
  17. HtlMysql();
  18. MYSQL_RES* p_res = NULL;
  19. //PreparedStatement* pstmt;
  20. public:
  21. MYSQL_ROW row;
  22. static HtlMysql* GetInstance();
  23. //连接数据库
  24. bool Connect(DBINFO& Dbinfo);//连接数据库
  25. const char* GetErrorInformation();//获取错误信息
  26. bool ExecutiveCommand(const char* SQLCommand);//执行命令
  27. MYSQL_RES* GetResultSet();//获取结果集
  28. ~HtlMysql();
  29. };