Important: Please read the Qt Code of Conduct -

Problems with QSQLite

  • hi guys, im cracking my head against the wall...i ve read the documentation and everything but i cannot make this work. I must say i m new to QT but here is what i do:
    qDebug() << QSqlDatabase::drivers();
    qDebug () << QCoreApplication::libraryPaths ();
    QSqlDatabase db;
    bool ok = ();
    if (ok)
    qDebug("%s", qPrintable(db.lastError().text()));

    ------------and this is the result:

    ("QSQLITE") <-- drivers intalled
    ("F:/QtSKD/Desktop/Qt/4.7.4/mingw/plugins", "C:/Documents and Settings/home/Escritorio/Los taninos-killgabio/GestionVinoteca-build-desktop/release")
    Driver not loaded Driver not loaded@

    in my .pro i have @QT += core gui sql@

    i cannot get the solution after all reading. Another thing i couldnt do is run nmake after doing qmake even though i downloaded the latest version...the thing is that when i run it i get these kind of errors: QSmallInt is not recognized bla bla...

    i really need a hand..thank u all

  • Just have another read on "QSqlDatabase":, especially the example, and I do not wonder that the compiler complains about QSmallInt, because there is no such class QSmallInt.

  • i was wrong about QSmaillInt sorry about that (when i run mingw32-make says that QString is not a type)

    what ever, my real problem is the driver not loaded, i tried placing qsqlite4.dll 's in my app folder but nothing i dont know what to do i been reading all day and i cant get and answer

    i dont know why this happens cause i installed the Qt skd latest version this morning and its supposed to have qsqlite ready to be used...

    Hope you can help.

  • No, your real problem is that your code is just wrong.
    // example taken from the QSqlDatabase documentation

    QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");

    // your code

    QSqlDatabase db;

  • Port 1521 is Oracle. PostgreSQL is usually 5432.

  • You can set credentials and port for sqllite database?

  • thank u all...the problem was the code :(

    but then again i have another question..i have an oracle database so the drivers i should use are QOCCI, right? the problem is that when i paste them on my plugins path of the QtSKD say`s that the drivers are not installed...

    what should i do? cause i read the documentation and i run the qmake it generates the files but when i run nmake the commandpromt tells that nmake is not a command...

    then again thank u all

  • The Qt oracle driver must be built manually. See the "Manual":/doc/qt-4.8/sql-driver.html for the instructions.

  • i followed the guide and finally, in the last step i get the error: nmake is not known as a command intern extern, program or file...

    so i tried to run mingw32-make and i get like tons of errors like it is not recognising any QT library

  • i just downloaded nmake pasted on the folder that i did the qmake...when i run the command nmake i get the same error as running it with mingw32-make....

    its my first time with Qt and im having a real headache

  • Just run nmake from the visual studio command prompt.

  • why should i have Visual Studio if im trying to install the OCI?? i think the problems are the dependencies with Qt cause the errors i get when trying to install them manually or building the .pro file with QtCreator are because it doesnt recognise QString and those libraries...


  • Ps: thanks everyone!

  • Which toolchain are you using? Visual Studio or MinGW?

  • MinGW and i run the command mingw32-make and i get the errors of the image :/

  • I can't remember my pass on qtcenter. I guess you are using qmake from QT console. The error you get using the console is normal. Run nmake or WhatEverYouWantMake using full path. c:/folder/builder/someting.exe.

  • same output...same fu*** errors.. sorry i dont know whats happening

  • Hey, temper temper. You might have something wrong with your env variables when you run from QtCreator. You said that you have copied qsqllite4.dll into the folder of your app, but this won't help. When deploying you must make a subdir called "sqldrivers" there you have to copy qsqllite4.dll if you run the release version or qsqllite4d.dll if you run the debug version. To be sure just copy both.
    Another thing if you have those two dlls then you definetly have sqllite support. The SDK version has it. If nothing works try uninstalling all and reinstall it again. However when I have compiled Qt as static from the vanilla sources I didn't have any problem in using qsqllite(do not use: -no-sql-sqlite and or -system-sqlite).

  • lol yes sorry. I have no problem with sqlite. Someone solved it by changing my code (ty someone) the problem now is how to install occi drivers cause i follow the documentation but nothing happens. I have an oracle database and i want to use it :/

  • i managed to get to this, but i cant solve the problem i cant find any lQtsqld in my system:
    mingw32-make -f Makefile.Debug all
    mingw32-make[1]: Entering directory F:/QtSKD/QtSources/4.7.4/src/plugins/sqldri vers/oci' g++ -mthreads -shared -Wl,--out-implib,f:\QtSKD\QtSources\4.7.4\plugins\sqldrive rs\libqsqlocid4.a -o ..\..\..\..\plugins\sqldrivers\qsqlocid4.dll tmp/obj/debug_ shared/main.o tmp/obj/debug_shared/qsql_oci.o tmp/obj/debug_shared/moc_qsql_oci. o tmp/obj/debug_shared/moc_qsqldriverplugin.o -L"f:\QtSKD\QtSources\4.7.4\lib" -L"%LIB%" -L"f:\oraclexe\app\oracle\product\11.2.0\server\oci\lib\msvc" -L"f:\Qt SKD\QtSources\4.7.4\lib" tmp\obj\debug_shared\qsqlocid_resource_res.o -loci -lQt Sqld -lQtCored f:/qtskd/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cann ot find -lQtSqld collect2: ld returned 1 exit status mingw32-make[1]: *** [..\..\..\..\plugins\sqldrivers\qsqlocid4.dll] Error 1 mingw32-make[1]: Leaving directoryF:/QtSKD/QtSources/4.7.4/src/plugins/sqldriv
    mingw32-make: *** [debug-all] Error 2 @

  • problem solved FUCK YEAH

  • Man, I have asked for help about MYSQL driver about 1 month ago(I am using qt static and want to obtain a lib not a dll). I have compiled and recompiled that small sqldriver project about 100 times:) Finally I got it, and released just an .exe with all QT features :)) I am glad you have managed to build a sqldriver on you own and hope that in future you will share your adventures :P

Log in to reply