I hav configued the Mysql successfully, now its showing QMYSQL in availabel drivers list.

I configured Mysql Server5.0 on my local machine and created database.

Using below code ,it connects to database but when I query it ,doesnt return any records,
so I tried checking my query with Query.lastquery() just before I execute it,and found that its returning blank.that means the query is not set properly ,what could be the error?

Qt Code:
  1. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
  2. QSqlQuery query;
  3. bool ok;
  4.  
  5. db.setHostName("localhost");
  6. db.setDatabaseName("ams");
  7. db.setUserName("root");
  8. db.setPassword("gauranga");
  9. db.setPort(3306);
  10.  
  11. if(!db.isOpen())
  12. ok = db.open();
  13.  
  14. if(!ok)
  15. {
  16. out << "\nError Driver text: " << db.lastError().driverText() ;
  17. out << "\nError Database text :" << db.lastError().databaseText();
  18.  
  19. }
  20. else
  21. {
  22. out <<"DB open successfully";
  23. ok = query.prepare("SELECT * FROM info");
  24. out << "\nQuery is: " << query.lastQuery();
  25. }
To copy to clipboard, switch view to plain text mode