[windows] qmysql driver not loaded
-
Hi! I'm currently trying to connect to a mysql database via QT. After searching around all day and yesterday trying to pinpoint whats been giving me this error I've yet to solve it and decided to try and ask myself as I'm rather new to mySQL and not too sure how this all works yet.
@ QSqlDatabase: QMYSQL driver not loaded@
@ QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7@I even went to a plain console application just to get this connection to work with no avail, Here's the code to that
@#include <QCoreApplication>
#include <QtSql/QSql>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlError>
#include <QString>
#include <iostream>int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);std::cout << "Beginning connection..\n";
// SQL database
QString servername = "www.db4free.net";
QString dbname = "ksyslancetest";
QString dbusr = "ksysusr";
QString dbpass = "ksyslance";
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setConnectOptions();
db.setHostName(servername);
db.setDatabaseName(dbname);
db.setUserName(dbusr);
db.setPassword(dbpass);if(db.open()) {
std::cout << "Success!";
} else {
std::cout << "failed\n";
QString error = db.lastError().text();
std::cout << error.toStdString();
}return a.exec();
}
@annnnnd .pro
@#-------------------------------------------------Project created by QtCreator 2014-08-04T10:37:07
#-------------------------------------------------
QT += core
QT += sqlQT -= gui
TARGET = qsqltest
CONFIG += console
CONFIG -= app_bundleTEMPLATE = app
SOURCES += main.cpp
@
I've done a myrid of other things trying to troubleshoot this so if you've any questions that could possibly help me please feel free to ask! Thank you! -
Hi and welcome to DevNet!
"This ":http://qt-project.org/forums/viewthread/41828/ may help you
-
Hi and welcome to devnet,
You also need to have the MySQL client dll containing folder in your PATH environment variable. You can update it in the Run part of the project panel