I'm trying to insert a date stamp into a MS Access DB column that is of type Date/Time. I can insert all the other values (which are text fields) fine. But when I attempt to add the field for Date the query doesn't work. Please help. Thanks!

Qt Code:
  1. QSqlQuery query;
  2. QDateTime currDate = QDateTime::currentDateTime();
  3.  
  4. query.prepare("INSERT INTO DwgHistory (historyDate, historyDwgNumber, historyDwgTitle, historyDwgEngineer, historyDwgDateToCad, historyDwgDateRequired, historyDwgDateReturnedFromCad, historyDwgDraftsman, historyDwgSource, historyDwgApprovedDate, historyDwgReleaseDate, historyDwgStatus, historyDwgPrecedence, historyDwgComments) "
  5. "VALUES (:historyDate, :historyDwgNumber, :historyDwgTitle, :historyDwgEngineer, :historyDwgDateToCad, :historyDwgDateRequired, :historyDwgDateReturnedFromCad, :historyDwgDraftsman, :historyDwgSource, :historyDwgApprovedDate, :historyDwgReleaseDate, :historyDwgStatus, :historyDwgPrecedence, :historyDwgComments)");
  6. query.bindValue(":historyDate", currDate.toString("MM-dd-yyyy")); //THIS IS THE PROBLEM.
  7. query.bindValue(":historyDwgNumber", aeddlg.addEditDwgNumberEdit->text());
  8. query.bindValue(":historyDwgTitle", aeddlg.addEditDwgTitleEdit->text());
  9. query.bindValue(":historyDwgEngineer", aeddlg.addEditEngineerEdit->text());
  10. query.bindValue(":historyDwgDateToCad", aeddlg.addEditDateToCadEdit->text());
  11. query.bindValue(":historyDwgDateRequired", aeddlg.addEditDateRequiredEdit->text());
  12. query.bindValue(":historyDwgDateReturnedFromCad", aeddlg.addEditDateReturnedEdit->text());
  13. query.bindValue(":historyDwgDraftsman", aeddlg.addEditDraftsmanEdit->text());
  14. query.bindValue(":historyDwgSource", aeddlg.addEditSourceEdit->text());
  15. query.bindValue(":historyDwgApprovedDate", aeddlg.addEditApprovedEdit->text());
  16. query.bindValue(":historyDwgReleaseDate", aeddlg.addEditReleasedEdit->text());
  17. query.bindValue(":historyDwgStatus", aeddlg.addEditStatusComboBox->itemText(aeddlg.addEditStatusComboBox->currentIndex()));
  18. query.bindValue(":historyDwgPrecedence", aeddlg.addEditPrecedenceEdit->text());
  19. query.bindValue(":historyDwgComments", aeddlg.addEditCommentsEdit->toPlainText());
  20.  
  21. if(!query.exec())
  22. {
  23. QMessageBox::warning(this, tr("Warning"),
  24. tr("Database Error: Unable to Insert New Entry into History"), QMessageBox::Ok);
  25. }
To copy to clipboard, switch view to plain text mode