PDA

View Full Version : Error Loading MySql Driver in 4.3.4



perrigo
26th March 2008, 08:48
Hello,
I've modified one of the Sql connector examples included with the Qt installation to connect to a mysql database. I'm using the eval version with MSVS 2005. The code compiles but when I try to call createConnection() I get a "Driver Not Loaded" error. The main thing I don't understand is that this worked under 4.3.3 but breaks now, even though 4.3.4 is completely backwards compatible. Here's the code. Thanks in advance.


#ifndef MYSQL_CONNECTION_H
#define MYSQL_CONNECTION_H

#include <QMessageBox>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QString>
#include <QStringList>
static bool createConnection()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setDatabaseName("scheduling");
db.setHostName("127.0.0.1");
db.setUserName("root");
db.setPassword("dora");
if (!db.open()) {
QMessageBox::critical(0, "Cannot open database",
"Unable to establish a database connection. " + db.lastError().text() + ".\n\n\n"
"Click Cancel to exit.", QMessageBox::Cancel);
return false;
}
return true;
}
#endif

patrik08
26th March 2008, 09:01
Hello,
I've modified one of the Sql connector examples included with the Qt installation to connect to a mysql database. I'm using the eval version with MSVS 2005. The code compiles but when I try to call createConnection() I get a "Driver Not Loaded" error. The main thing I don't understand is that this worked under 4.3.3 but breaks now, even though 4.3.4 is completely backwards compatible. Here's the code. Thanks in advance.
#endif

if you run demo application
Qt/4.3.3_src/demos/sqlbrowser/release
you can see all loaded Driver if see QMYSQL driver can work otherwise have a look on wiki to install...

perrigo
26th March 2008, 09:23
QMYSQL isn't among the options in the "Driver" combo box. Only QSQLITE, QODBC, and QPSQL are available.

Tiansen
26th March 2008, 09:51
I have exactly the same problem.

patrik08
26th March 2008, 11:05
I have exactly the same problem.

i try 4 week a go on Microsoft Visual Studio 2008 beta the qt build -qt-sql-mysql run and work.. but now i use a MingW compiler qt build ( less dll )

grab mingw compiler from ftp://ftp.trolltech.com/qt/source/qt-win-opensource-4.4.0-beta1-mingw.exe
and build ftp://ftp.trolltech.com/qt/source/qt-win-opensource-src-4.3.0.zip -qt-sql-mysql
like http://wiki.qtcentre.org/index.php?title=Building_the_QMYSQL_plugin_on_Wind ows_using_MinGW

perrigo
26th March 2008, 14:38
You see, I would rather solve my problem than avoid it. I'm using VS 2005 and would like for the code to work. The exact same code ran correctly in 4.3.3. If anyone has gotten the MySql driver to load please include a bit of sample code. Thanks.