PDA

View Full Version : mysql is installed but can not load



vanduongbk
7th July 2013, 15:25
hi everyone,i have install mysql on window with vs2008 complete
but when i test a code as belows,it can not load ,plz help
this is a test code:


#include <QCoreApplication>
#include <QtSql>
#include <QDebug>

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QSqlDatabase db=QSqlDatabase::addDatabase("qmysql","db");
db.setHostName("testmysql");
db.setDatabaseName("testdb");
db.setUserName("vanduongbk");
db.setPassword("sa123");
if(!db.open())
{
qDebug()<<"error connect"<<db.lastError().text();
}
else
{
qDebug()<<"connected";
}
//MainWindow w;
// w.show();

return a.exec();
}


when compile,it have error as :
Starting C:\Documents and Settings\vanduongbk\My Documents\myqtproject\build-mysqlproject1-Desktop-Debug\debug\mysqlproject1...
QSqlDatabase: qmysql driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL3 QMYSQL QODBC3 QODBC QPSQL7 QPSQL
error connect "Driver not loaded Driver not loaded"

p3c0
7th July 2013, 16:06
Have a look at
http://www.qtcentre.org/threads/20668-MySQL-driver-I-have-it-still-not-loaded
if it solves your problem