//update computer void inputComp(int& numOfCom, QSqlDatabase& db) { bool db_ok = db.open(); if(db_ok) { QString full_info = ""; QString inputComp = "INSERT INTO Computer (name, year_creation, type, was_built) VALUES "; QSqlQuery query(db); NumOfComp(numOfCom); for(int i = 0; i < numOfCom; i++){ Computer Com = setComputer(); full_info.append("(\""); full_info.append( QString::fromStdString(Com.getname())); full_info.append("\", "); full_info.append( QString::number(Com.getyearcreated())); full_info.append(", \""); full_info.append( QString::fromStdString(Com.gettype())); full_info.append("\", "); full_info.append( QString::number(Com.getwascreated())); full_info.append(")"); if(i >= numOfCom-1){ full_info.append(";"); } else full_info.append(","); } inputComp.append(full_info); bool prepared = query.prepare(inputComp); if(prepared){ query.exec(); } else cout << query.lastError().text().toStdString() << endl; //report error } else cout << "db.open() returned false" << endl; db.close(); }