Qt World Summit: Register Today!

Qodbc driver not loaded

  • Hi i try to create a dll witch connects over ODBC to a microsoft SQL Database. I create and use the dll in VisualStudio projects.
    But i get the error QODBC driver not loaded.

    I had a simular problam as i tried to create an exe witch connects to a DB over ODBC and execute it on a machine without QT installation. There was the solution to create a folder in the path of the exe called sqldrivers and in it the needed dll qsqlodbc4.dll.

    I think the problem is that the dll needs the qsqlodbcd4.dll but i don´t know how to include this in my project.
    I tried it this way
    @QLibrary lib(QLatin1String("C:\Programme\DEMCenter\bin\sqldrivers\qsqlodbcd4.dll"));
    QtPluginInstanceFunction pInstanceFct = 0;
    QObject* pAccPlugin = 0;
    pInstanceFct = (QtPluginInstanceFunction)lib.resolve("qt_plugin_instance");

    if(0 != pInstanceFct)
    INFO("dllNOT LOADED");@

    But it dosn´t work it runs everytime in the else and tell me that the dll is not loaded

    Hope someone can help me


  • This is the error message i become when i try to connect to the odbc database

    QSqlDatabase: QODBC driver not loaded
    QSqlDatabase: available drivers:
    QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins

  • How did you setup the application where your dll failes? Try to make a minimal program that loads your SQLdll. Normally there's no need to load the plugin driver manually.

  • Hi I tried it with a smal programm. When I run the programm with the dll on a maschine where QT is installed everythink runs fine. But when i run the programm on a pc without a qt installation i can´t connect to the database.

    I although tried to connect to the database in a programm without a dll. On the pc with qt everythink runs fine. On the maschine without qt i had to copy the qsqlodbc4.dll and after that it worked.

    So i gues i need to load the qsqlodbc4.dll manually that my dll can find the plugin but i don´t know how to do it

  • Hi again.

    No one an idear? I tried to fix the Problem. But i can´t finde a solution. Is there a way to set the path to the plugin folder? To set QTPATH is not working
    I found ways to it inside a normal QT project but not in an dll.

    The reason why my dll works on a maschine where qt is installed is that in QTCore4.dll qt_plugpath=D:\Qt\4.8.2\plugins is set where my qt plugins are.
    But on the maschine where my project should run is no QT installation an no d:\



Log in to reply