I have two databases im working with. They are both for different form interfaces. One works but the other database doesn't show any changes when I make an update and I get no errors in my code so it's quite difficult to troubleshoot. Here is a listing of my db setup and where I update in both:

The working db:
Qt Code:
  1. #include <QtSql>
  2.  
  3. #define Path_to_DB "/media/.../dbpath"
  4.  
  5. .....
  6.  
  7. {
  8. ui->setupUi(this);
  9. db = QSqlDatabase::addDatabase("QSQLITE");
  10. db.setDatabaseName(Path_to_DB);
  11. QFileInfo checkFile(Path_to_DB);
  12.  
  13. if(checkFile.isFile())
  14. {
  15. if(db.open())
  16. {
  17. qDebug() << "Connected to database file";
  18. }
  19. }else{
  20. qDebug() << "Database file not found";
  21. }
  22. }
  23.  
  24. adminDialog::~adminDialog()
  25. {
  26. delete ui;
  27. qDebug() << "Closing connection to Database file on exit...";
  28. db.close();
  29. }
  30.  
  31. double count;
  32.  
  33. void adminDialog::on_pushButton_3_clicked()
  34. {
  35. count++;
  36. QString str = ui->lineEdit->text();
  37. ui->count->display(count);
  38.  
  39. qDebug() << str;
  40.  
  41. if(!db.isOpen()){
  42. qDebug() << "No connection to db";
  43. return;
  44. }
  45.  
  46. QSqlQuery query;
  47.  
  48. QString qry = QString("INSERT INTO customer (name, size1, size2, size3) VALUES ('%1', NULL, NULL, NULL)").arg(str);
  49.  
  50. query.prepare(qry);
  51. if(query.exec())
  52. {
  53. qDebug() << "Update Complete";
  54. }
  55. else
  56. {
  57. qDebug() << query.lastError();
  58. }
  59. }
To copy to clipboard, switch view to plain text mode 

db thats not working:

Qt Code:
  1. #include <QtSql>
  2.  
  3. #define Path_to_DB "/media/.../db2path"
  4. ......
  5.  
  6. ui->setupUi(this);
  7. db2 = QSqlDatabase::addDatabase("QSQLITE");
  8. db2.setDatabaseName(Path_to_DB);
  9. QFileInfo checkFile(Path_to_DB);
  10.  
  11. if(checkFile.isFile())
  12. {
  13. if(db2.open())
  14. {
  15. qDebug() << "Connected to database file";
  16. }
  17. }else{
  18. qDebug() << "Database file not found";
  19. }
  20. }
  21.  
  22. void demo::on_pushButton_clicked()
  23. {
  24. if(!db2.isOpen()){
  25. qDebug() << "No connection to db";
  26. return;
  27. }
  28. ........
  29.  
  30. QSqlQuery query;
  31. switch (md_pref)
  32. {
  33. case 1:
  34. query.prepare("UPDATE customer SET size1 = size1 + 1 WHERE name = 'Gary' ");
  35. if(query.exec())
  36. {
  37. qDebug() << "Updated Gary";
  38. }
  39. else
  40. {
  41. qDebug() << query.lastError();
  42. }
  43. break;
  44. .............
  45.  
  46. }
To copy to clipboard, switch view to plain text mode 

I'm working on a Linux Kubuntu 12.10 system. I appreciate all help on this thanks.