nomanbinhussein
18th December 2015, 19:18
I'm using Qt 5.5 with MSVC plugin. I want to simply connect to a database. The code is -
QString hostName = "127.0.0.1";
QString databaseName = "imagedatabase";
QString userName = "demouser";
QString userPass = "demopass";
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName(hostName);
db.setDatabaseName(databaseName);
db.setUserName(userName);
db.setPassword(userPass);
bool ok = db.open();
But the following error occurs -
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
Then following some suggestion in the web - I copied the qsqlmysql.dll, qsqlmysqld.dll,libmysql.dll, libmysqld.dll files to the project folder. -that didn't work. According to another thread here - I have to put mysqlclient.lib where my application executable is. But I use a wampserver mysql where I don't have a mysqlclient.lib file.
How can I complete this simple task?
QString hostName = "127.0.0.1";
QString databaseName = "imagedatabase";
QString userName = "demouser";
QString userPass = "demopass";
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName(hostName);
db.setDatabaseName(databaseName);
db.setUserName(userName);
db.setPassword(userPass);
bool ok = db.open();
But the following error occurs -
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
Then following some suggestion in the web - I copied the qsqlmysql.dll, qsqlmysqld.dll,libmysql.dll, libmysqld.dll files to the project folder. -that didn't work. According to another thread here - I have to put mysqlclient.lib where my application executable is. But I use a wampserver mysql where I don't have a mysqlclient.lib file.
How can I complete this simple task?