What do I need to do to have the connection and queries in the header file? If put the function in to test if the mxtrainer is there to see if it is the first time the program has run. If it is the first time, create the table. If not use the existing data. Where is the tool for single stepping through the code...I have been using breakpoints to try and find the problems. I got rid of the test and put in QSqlQuery::Last error like this:
Qt Code:
  1. void createDb()
  2. {
  3. QSqlQuery query;
  4. //query.exec("DROP TABLE scooter");
  5.  
  6. query.exec("CREATE TABLE rider ("
  7. "id INTEGER PRIMARY KEY AUTOINCREMENT, "
  8. "name VARCHAR(20) NOT NULL, "
  9. "weight INTEGER NOT NULL, ");
  10. query.exec("INSERT INTO rider (name, weight) "
  11. "VALUES ('Villapoto', 155");
  12. query.exec("INSERT INTO rider (name, weight) "
  13. "VALUES ('Carmichael', 165");
  14. query.exec("INSERT INTO rider (name, weight) "
  15. "VALUES ('McGrath', 175");
  16. qDebug() << query.lastError();
  17. }
  18. int main(int argc, char *argv[])
  19. {
  20. QApplication a(argc, argv);
  21. //bool create = !QFile::exists("mxtrainer.dat");
  22. //if (!createConnection())
  23. //return 1;
  24. //if (create)
  25. createDb();
  26. MXMainWindow w;
  27. w.show();
  28.  
  29. return a.exec();
  30. }
To copy to clipboard, switch view to plain text mode 
I got an error database not open.
Where do I go from here?
PS. I really appreciate all your help!!