Connection to a MySQL database with Qt Creator on Windows
-
@Justin_Ahinon said in Connection to a MySQL database with Qt Creator on Windows:
QMYSQL
Hi
Did you try with fresh install of Qt? -
@Justin_Ahinon
If this error occurred also with SQLITE, then check if you have in your *.pro file something like this:QT += sql
-
Hi,
To add to my fellow, do you have the MySQL client libraries available on your system ?
-
Run your application with the QT_DEBUG_PLUGINS environment variable set to 1 to see what is happening.
You can set that variable in the Run part of the project panel.
-
I would make sure you complie the mysql plugin..
- make sure you have installed mysql the same lib headers for x86 or x64.
- open mysql plugin located in qbase you will have to comment out a few things as they still havnt fix the bug yet.
- copy those libs and dlls into your complier folder
- copy mysqlclient.dll and qt5sql.dll into your .exe folder
- should be all set...
-
Hi every body,
I solve the problem by using the QSQLITE driver which is installed with Qt./.pro file QT += widgets sql
//.cpp file bool createConnection() { QSqlDatabase laBase = QSqlDatabase::addDataBase("QSQLITE"); laBase.setHostName("localhost"); laBase.setDataBaseName("test"); laBase.setUserName("justin"); laBase.setPassword("******"); if (!laBase.open()){ QMessageBox:: critical (0 /* ... */ ); QObject::tr("Error"), laBase.lastError().text()); return false; } return true; }
-
Hi,
Are you aware of the implications of moving from MySQL to SQLite ?
One of which is: you are using a relative path for your SQLite database which won't work if your users install your application in e.g.
Program Files
as it's a read-only location.