Driver Not Loaded SQLITE
Unsolved
Installation and Deployment
-
It has been more than a year that i have not use QT. My old computer died so i have a fresh installation of QT. I was refreshing my programming memory and tried to create a database with sqlite, but when i tried to run i get the error "Driver not loaded". I remember having the same problem a couple of years ago but cannot remember how to solve.
QSqlDatabase myDatabase; myDatabase.database("QSQLITE"); myDatabase.setDatabaseName("email"); qDebug() << "Here"; qDebug() << QSqlDatabase::drivers(); if(!myDatabase.open()){ qDebug() << "Error"; qDebug()<< myDatabase.lastError(); } Here ("QSQLITE", "QMYSQL", "QMYSQL3", "QODBC", "QODBC3", "QPSQL", "QPSQL7") Error QSqlError("", "Driver not loaded", "Driver not loaded")
-
I think you are using myDatabase.database("QSQLITE") wrongly.
From documentation:[static] QSqlDatabase QSqlDatabase::database(const QString &connectionName = QLatin1String( defaultConnection ), bool open = true) Returns the database connection called connectionName. The database connection must have been previously added with addDatabase(). If open is true (the default) and the database connection is not already open it is opened now. If no connectionName is specified the default connection is used. If connectionName does not exist in the list of databases, an invalid connection is returned.
The other things you can check are:
- Do you have something like this in *.pro file:
QT += sql
- If your project is compiled in Release mode, do you have plugin in your application folder: sqldrivers/qsqlite.dll (this is for Windows).