查询数据
//查询数据源 QSqlQuery searchDataSource(ESSystemConfig esSystemConfig,QString sqlParam) {//连接数据库 ESDatabaseCommon esDatabaseCommonObj1; QString databaseUserName = esSystemConfig.getUserName();//数据库连接用户名 QString databaseUserPwd = esSystemConfig.getUserPwd();//数据库连接用户密码 QString databaseAddress = esSystemConfig.getDatabaseAddress();//数据库连接地址 QString databasePort = QString::number(esSystemConfig.getDatabasePort());//数据库连接端口号 QString databaseLinkName = esSystemConfig.getLinkName();//数据库连接名 QString databaseName = esSystemConfig.getDatabaseName();//数据库名 int databaseType = 1;//1:Mysql 2:Oracle 3:SqlServer 4:PostgreSQL esDatabaseCommonObj1.setConnectParam(databaseUserName, databaseUserPwd, databaseAddress, databasePort, databaseLinkName, databaseName, databaseType); bool isConnect = esDatabaseCommonObj1.connectDatabase(); QSqlQuery qSqlQueryObj; if (isConnect) { qSqlQueryObj = esDatabaseCommonObj1.execSearchSql(sqlParam);
esDatabaseCommonObj1.closeDatabase(); } return qSqlQueryObj; }