⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 database.h

📁 为电力系统开发保护设备装置通讯的源代码 采用串口通讯, ret hat 9下 QT开发
💻 H
字号:
#include <stdio.h>#include <libpq-fe.h>#include <qcstring.h>#include <qstringlist.h>#include <libpq/libpq-fs.h>#include <fcntl.h>#include <stdlib.h>#include <linux/ext2_fs.h>#include <unistd.h>#include <sys/ioctl.h>#include <sys/types.h>#define BUFSIZE                  1024class CDataBase{    public:    CDataBase();    ~CDataBase();    public:    bool ConnectDataBase();						//连接数据库    bool ConnectDataBase(long &hdbc,QCString dbname,			 QCString dbuser,QCString dbpass);			//连接数据库    bool DisConnectDataBase(long &hdbc);					//断开数据库    int SqlExec(long hdbc,QCString SqlStr);				//执行一个SQL语句    long SqlSelect(long hdbc,QCString SqlStr,long &result);			//查询数据;返回记录数    int  GetRecordCount(long result);					//得到记录数    int  GetFieldCount(long result);					//得到字段数量    QCString GetFieldName(long result,unsigned int iField);			//得到字段名称    int GetFieldType(long result,unsigned int iField);				//得到字段类型    QCString GetFieldValue(long result,unsigned int iRow,unsigned int iField);	//得到字段值    void ClearResult(long &result);						//释放结果内存    //使用游标查询数据库    bool OpenCursor(long hdbc,QCString SqlStr,long &pCursor);		//打开一个光标    bool FetchPriorRow(long hdbc,long pCursor,long &result);			//读取当前记录的上一条记录    bool FetchNextRow(long hdbc,long pCursor,long &result);			//读取当前记录的下一条记录    bool FetchAllRow(long hdbc,long pCursor,long &result);			//读取所有记录    void CloseCursor(long hdbc,long &pCursor);				//关闭光标    //大文本对象的处理    bool InsertWithLargeObject(long hdbc,QCString SqlStr,QStringList FileList); //插入大对象    bool DeleteWithLargeObject(long hdbc,QCString Table,QCString WhereStr,QStringList FieldList,			       bool bForceDele=0,bool bDeleRow=1);    //删除大对象    bool UpdateLargeObject(long hdbc,QCString SqlStr,QStringList FileList);   //修改大对象    public:    QCString FillParam(QCString SqlStr,int ParamIndex,int ParamType,		       QCString param);                           //填充参数    void GetTableFromSql(QCString SqlStr,QCString &Table,QCString &WhereStr,QStringList &FieldList);      Oid importfile(long hdbc,char *filename);    bool pickout(long hdbc,Oid objId,int start,int len,void* retbuf);    bool overwrite(long hdbc,Oid lobjId,int start,int len,void* srcbuf);    bool exportfile(long hdbc,Oid objId,char *filename);    public:    PGconn 		      *m_pconnect;    QCString   			m_pghost;    QCString 			m_pgport;    QCString			m_pgoptions;    QCString			m_pgtty;    QCString			m_dbname;    QCString			m_dbuser;    QCString			m_dbpassword;    //引入影射变量    long 			 m_hdbc;    bool                     m_bconnect;    };

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -