hi there, the function exec() in the code below returns false all the time and I've tried everything to fix it but without any success. Could I be missing something here. please help.
Qt Code:
  1. void MainWindow::query(QStringList qry)
  2. {
  3. QString qryStr = QString("INSERT INTO Modules VALUES(\"%1, %2 %3 %4\")").arg(qry.at(0)).arg(qry.at(1)).arg(qry.at(2)).arg(qry.at(3));
  4. QSqlQuery query;
  5. query.prepare(qryStr);
  6.  
  7. if(query.exec())
  8. QMessageBox::critical(0, "DB Status","DATABASE UPDATED", QMessageBox::Ok);
  9. else
  10. QMessageBox::critical(0, "DB Status","DATABASE NOT UPDATED", QMessageBox::Ok);
  11. }
To copy to clipboard, switch view to plain text mode