It is infinitely more likely that the database is not what you think it is. If "rider.dat" already exists then it will be opened, otherwise it is created. If it already existed and the table rider already exists then your CREATE TABLE will fail leaving whatever structure was previously there. Depending on the structure this could cause your subsequent INSERTs to also fail, leaving whatever data was in the table still in the table. Delete rider.dat before you try again.

query.lastError() will return a QSqlError object that has some useful members. There's no point looking at it if the exec() indicated it succeeded though.
Qt Code:
  1. void createDb()
  2. {
  3. QSqlQuery query;
  4. bool ok;
  5.  
  6. ok = query.exec("CREATE TABLE rider (id INTEGER PRIMARY KEY AUTOINCREMENT, "
  7. "LName TEXT, FName TEXT, weight REAL, notes TEXT)"); //Table creates properly with all the fields
  8. if (!ok) qWarn() << query.lastError().text();
  9. ok = query.exec("INSERT INTO rider (FName, LName, weight)"
  10. "VALUES ('Ryan', 'Villapoto',185)"); // Villapoto gets put into table as FName
  11. if (!ok) qWarn() << query.lastError().text();
  12. ok = query.exec("INSERT INTO rider (FName, LName, weight)"
  13. "VALUES ('Jeremy', 'McGrath',155)"); // Nothing gets added
  14. if (!ok) qWarn() << query.lastError().text();
  15. }
To copy to clipboard, switch view to plain text mode