I am using VS2008 & QT plugin to make my application. After making package when I am running the application I am getting error :
QSqlDatabase: QSQLITE driver not loaded
QSqlDatabase: available drivers:
Database error: QSqlError(-1, "Driver not loaded", "Driver not loaded")
QSqlError(-1, "Driver not loaded", "Driver not loaded")
I have added the qsqlite.dll to my package & also changed the libpath. But still I am getting this error. How to solve this.
My Code::
QStringList str;
str.append(".");
a.setLibraryPaths(str);
a.addLibraryPath("./sqldrivers/");
//a.addLibraryPath(".");
qDebug()<<"my library path : "<<a.libraryPaths();
QLibrary sqlib("qsqlite4.dll");
sqlib.load();
qDebug()<<"my library loaded"<<sqlib.isLoaded();
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
qDebug()<<"Database error:"<<db.lastError();
db.setDatabaseName("vimukti1234");
qDebug()<< db.lastError();
db.open();
QSqlQuery query;
Try this first:
to check available Drivers.
Just Add dll file which have folder life platform and drivesr
so simply build app using windeployqt tool
The drivers need to be placed under "sqldrivers", not in the same directory as the executable (they are loaded on runtime, and Qt looks for them in "sqldrivers"). A typical structure of one of our installed applications is like this:
Well, the function: addDatabase("QSQLITE"); takes two parameters, the first is the driver and the second is the name of your connection, (passed as a QString)
Now, try the following:
It worked for me, so I guess it'll work for you. (Assuming SQLITE is among your installed drivers)
You can check for SQLITE by the following:
Good luck!
Zaher J.G.