I Use My SQL and i developped my application on QT. I see many answer about my question but, the question was old and, i have an other probleme less speake.
my code it's just this :
#include <stdlib.h>
#include <stdio.h>
#include <QtSql>
int main(int argc, char *argv[])
{
printf("Hello wordl ! \n");
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("meropyDatabase");
db.setUserName("User");
db.setPassword("ApplicationUser21!");
bool ok = db.open();
printf("Data base : %d \n",ok);
//QSqlQuery query;
db.exec("INSERT INTO Users (FirstName,LastName,IDCompany,EmailAddress) VALUES ('Jean','MICKEL',1,'jean.mickel@hotmail.fr')");
printf("erreur : %s \n",db.lastError().text().toStdString().c_str());
return 0;
}
And i have this error message :
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins
QSqlQuery::exec: database not open
Hello wordl !
Data base : 0
erreur : Driver not loaded Driver not loaded
Today, i don't understand what make i for take work this...
For the option available drivers MYSQL is not here I try to add different dll but not change....
I have juste change when i use QSQLITE but, it's connect on my database but it's don't find the table...
i use QT 5.15 and MySQL 8.0
In try to test this tuto : https://doc.qt.io/qt-5/sql-driver.html for window,
the first step it's ok, i discover the correcly directory,
But, for the second step : "qmake MYSQL_INCDIR="C:\Program Files\MySQL\Connector C++ 8.0\include" MYSQL_LIBDIR="C:\Program Files\MySQL\Connector C++ 8.0\lib64""
I have this message:
Running configuration tests...
Done running configuration tests.
Configure summary:
Qt Sql Drivers:
DB2 (IBM) .............................. no
InterBase .............................. no
MySql .................................. no
OCI (Oracle) ........................... no
ODBC ................................... no
PostgreSQL ............................. no
SQLite2 ................................ no
SQLite ................................. yes
Using system provided SQLite ......... no
TDS (Sybase) ........................... no
Qt is now configured for building. Just run 'nmake'.
Once everything is built, you must run 'nmake install'.
Qt will be installed into 'C:\Qt\5.15.2\msvc2019_64'.
Prior to reconfiguration, make sure you remove any leftovers from
the previous build.
and nmake or mingw32-make don't work for n make i have this error :
rc /NOLOGO -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DQT_NO_LINKED_LIST -DQT_NO_JAVA_STYLE_ITERATORS -DNDEBUG -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_OMIT_COMPLETE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_JSON1 -DSQLITE_OMIT_LOAD_EXTENSION -DQT_DEPRECATED_WARNINGS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DNDEBUG -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -D_WINDLL -fo .obj\release\qsqlite_resource.res qsqlite_resource.rc
qsqlite_resource.rc(1) : fatal error RC1015: cannot open include file 'windows.h'.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\rc.EXE"' : code retour '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\Hostx64\x64\nmake.exe"' : code retour '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : code retour '0x2'
Stop.
En effect, i don't find the file windows.h or the other file for QT...