Hi Guys,

I am working on a small command line application in which I need basic MySQL connectivity. I am using Qt Creator 2.4.1 with Qt 4.7.4 on Windows 7. I created a "Qt Console Application" project and tried to compile the following trivial program.

Qt Code:
  1. #include <QtCore/QCoreApplication>
  2. #include <QtSql/QSqlDatabase>
  3.  
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. int main(int argc, char *argv[])
  9. {
  10. QCoreApplication a(argc, argv);
  11. QSqlDatabase myDb = QSqlDatabase::addDatabase( "QMYSQL" );
  12.  
  13. myDb.setHostName( "localhost" );
  14. myDb.setUserName( "root" );
  15. myDb.setPassword( "*********" );
  16. myDb.setDatabaseName( "mytestdb" );
  17.  
  18. bool success = myDb.open();
  19.  
  20. if ( success ) cout << "Database connection established successfully" << endl;
  21. else cout << "Database connection failed" << endl;
  22.  
  23. myDb.close();
  24.  
  25. QSqlDatabase::removeDatabase( myDb.database().connectionName() );
  26.  
  27. return a.exec();
  28. }
To copy to clipboard, switch view to plain text mode 

On building this project, I get following, about 18 errors.
Please tell me what am I doing wrong and where?
Thanks!!!