Qt QSqlDatabase ODBC and MySQL connection
Hi!
I noticed, that there are many problems establishing MySQL connection using ODBC driver, and many don’t want to recompile Qt with MySQL driver.
This connection is for ODBC driver 3.51! It will not work with 5.1.
Here is how it goes with ODBC:
- db.setDatabaseName("Port=YourPort;Server=YourServerIP;Driver={MySQL ODBC 3.51 Driver};User=YourUsername;Password=YourPassword;Database=YourDatabaseName;");
Make sure that you have correct version ( 3.51) of ODBC driver installed ( download [dev.mysql.com] from MySQL website).
To open connection and print error if connetion failed:
- if(!db.open())
- qDebug() << db.lastError().databaseText()
Hope it helps.
Regards,
Jake
1 reply
You must log in to post a reply. Not a member yet? Register here!



