QSqlQuery::exec: database not open
QSqlQuery conAccessDB::excuteSQL(QString sqlcmd){ if(!db.open()){ qDebug() << "Database Error: " << db.lastError().text(); return QSqlQuery(); } if(!query.exec(sqlcmd)){ qDebug() << "Database Error: When excute \"" << sqlcmd << "\""; db.close(); return QSqlQuery(); } db.close(); return query; }
QSqlQuery conAccessDB::excuteSQL(QString sqlcmd){ if(!db.open()){ qDebug() << "Database Error: " << db.lastError().text(); return QSqlQuery(); } QSqlQuery myQuery(db);if(!myQuery.exec(sqlcmd)){ qDebug() << "Database Error: When excute \"" << sqlcmd << "\""; db.close(); return QSqlQuery(); } db.close(); return myQuery; }