lundi 8 juin 2015

Qt and SQLite, error when executing query, without error message

I am using Qt 5.4 and SQLite to to database operations, all other requests work, but this one doesn't seem to work and gives no error.

   QSqlQuery query(Globals::db);

   QString cmd = "Update VideoFile set isVisible = 0 WHERE Id  =1;";
   if(query.prepare(cmd))
       qDebug("Prepare success..."); //<-- prints out


 if (!query.exec()) {
     qDebug("Error occurred querying.");
     qDebug("%s.", qPrintable(Globals::db.lastError().text())); //<<-- prints out blank

 }

Tried so far:

o) Database: exists!

o) Query Prepare() yields True

o) When executing the same Statement in SQLite Browser. Works!

i read about a problem here:, that some databases have a certain delay.

"Portability note: Some databases choose to delay preparing a query until it is executed the first time. In this case, preparing a syntactically wrong query succeeds, but every consecutive exec() will fail." But apparently, the query is not syntactically wrong.

Aucun commentaire:

Enregistrer un commentaire