Skip to content
  • 0 Votes
    4 Posts
    422 Views
    P

    Hello,

    to make easy solution I just changed the databaseName when I need the other database and go back to the first databaseName when I don't need the second db :

    databaseManager::databaseManager() { QDir dir; dir.setPath("./Databases"); if (!dir.exists()){ dir.mkdir("."); } db=QSqlDatabase::addDatabase("QSQLITE"); databaseName="./Databases/battery.sqlite"; db.setDatabaseName(databaseName); dbInitCheckStep(); } void databaseManager::dbInitCheckStep() { db.open(); { QSqlQuery query; qDebug()<<"query.exec()"<< query.exec("CREATE TABLE IF NOT EXISTS check_data (step TEXT, periodical_CheckOk TEXT, periodical_CheckNo TEXT,regular_CheckOk TEXT, regular_CheckNo TEXT,general_OverhaulOk TEXT, general_OverhaulNo TEXT, rtos_aft_short_storageOk TEXT, rtos_aft_short_storageNo TEXT)"); query.finish(); query.clear(); db.close(); } QSqlDatabase::removeDatabase("QSQLITE"); } QStringList databaseManager::comboListOtMat() { QStringList listCheck; db.setDatabaseName("../Software32/Databases/kardexdb.sqlite"); db.open(); { QSqlQuery query; query.exec("SELECT otnumber FROM ot_log where ottype='EQUIPMENT' and description='BATTERY' order by cast (substr(otnumber, -2) as decimal) desc, cast(substr(otnumber,1,2) as decimal) desc"); while(query.next()) { qDebug()<<query.value(0).toString(); listCheck<<query.value(0).toString(); } query.finish(); query.clear(); db.close(); } QSqlDatabase::removeDatabase("QSQLITE"); db.setDatabaseName("./Databases/battery.sqlite"); return listCheck; }

    it's not beautyfull but it's easy and it's working fine ;-)