I have a MS Access 2003 database that I can hook into and query for results (ie SELECT column FROM table ...) and navigate the results. However, I am not able to insert anything programatically. I can if I go into the table via the MS Access GUI. The thing that is causing me concern is if I use the QSqlDriver::sqlStatement and return back all of the different statements, it only gives me statements for Select, where, and delete, but not for insert or update:

Qt Code:
  1. QSqlQuery query;
  2. QSqlDriver const * driver = query.driver();
  3. QSqlRecord rec = driver->record("testTbl");
  4. QString insertStatement = driver->sqlStatement(QSqlDriver::InsertStatement,"testTbl",rec,true);
  5. QString selectStatement = driver->sqlStatement(QSqlDriver::SelectStatement,"testTbl",rec,true);
  6. QString updateStatement = driver->sqlStatement(QSqlDriver::UpdateStatement,"testTbl",rec,true);
  7. QString deleteStatement = driver->sqlStatement(QSqlDriver::DeleteStatement,"testTbl",rec,true);
  8. QString whereStatement = driver->sqlStatement(QSqlDriver::WhereStatement,"testTbl",rec,true);
  9.  
  10. qDebug() << " Insertstatement " << insertStatement << endl;
  11. qDebug() << " Selectstatement " << selectStatement << endl;
  12. qDebug() << " Updatestatement " << updateStatement << endl;
  13. qDebug() << " Deletestatement " << deleteStatement << endl;
  14. qDebug() << " Wheretstatement " << whereStatement << endl;
To copy to clipboard, switch view to plain text mode 

This code returns this:

Insertstatement ""
Selectstatement "SELECT RecNum, UniqueID FROM testTbl"
Updatestatement ""
Deletestatement "DELETE FROM testTbl"
Wheretstatement "WHERE RecNum = ? AND UniqueID = ?"

If I try to do it writing my own SQL insert statement, it "executes" but nothing goes into the table. I added the call to query.exeutedquery() and it returns an empty string.

Qt Code:
  1. if(!query.exec("INSERT INTO testTbl VALUES (10,20)"))
  2. {
  3. qDebug() << query.lastError().text();
  4. return false;
  5. }
  6.  
  7. QString executedQuery(query.executedQuery());
  8. qDebug() << "executed query " << executedQuery << endl;
To copy to clipboard, switch view to plain text mode 

executed query ""

Can anyone tell what Im missing? It's probably obvious... except to me

TIA