Hi all,

I never saw this behavior before, so I'm a well bit confused, maybe I'm missing something stupid.
I built a minimal application just to test QMYSQL driver to use it in another project; the problem is that it connects, but queries are executed or not depending on how I do it:

-QSqlQuery::exec(QString query); -> works
-QSqlQuery::prepare(QString query); QSqlQuery::exec(); -> doesn't

no errors from the db, it just fails.
Someone knows why whould happen something like that?

This is the code I use:
Qt Code:
  1. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
  2. db.setHostName("localhost");
  3. db.setDatabaseName("dbname");
  4. db.setUserName("username");
  5. db.setPassword("password");
  6. bool ok = db.open();
  7. if(ok)
  8. {
  9. QMessageBox::information(this,"Connected","Database is connected");
  10. QSqlQuery query(db);
  11. query.prepare("SELECT * FROM categories");
  12. if(!query.exec()) // instruction: query.exec("SELECT * FROM categories") would work
  13. QMessageBox::critical(this,"Query error",db.lastError().text()); //no errors... but fails
  14. db.close();
  15. }
  16. else
  17. QMessageBox::critical(this,"Connect error",db.lastError().text());
To copy to clipboard, switch view to plain text mode 
By the way, categories table exists in that db.

Anybody? Thanks in advance