Problem with connecting to postgres database

  • I'm newbie, and I'm trying to connect to postgres databes with following code:
    QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
    bool ok =;
    QSqlError err=db.lastError();

    I can't open the connection, I get following output:

    First-chance exception at 0x76fb1d82 in qttest1.exe: 0xC0000138: Ordinal Not Found.
    'qttest1.exe': Unloaded 'C:\Qt\5.2.0\msvc2010\plugins\sqldrivers\qsqlpsqld.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\libpq.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\wsock32.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\ssleay32.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\shfolder.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\krb5_32.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\libintl-2.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\libiconv-2.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\libeay32.dll'
    'qttest1.exe': Unloaded 'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57\msvcr90.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\comerr32.dll'
    QSqlDatabase: QPSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

    It seems, that a dll leaks a function. I'm using QT 5.2.0 on Windows 7 Pro. What can I do to get the simple method working?

    with regards

    Rafal Ziolkowski

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Just an educated guess, are you sure your postgresql dlls are all up to date ? Or at least the same used to compile the plugin ?

  • hallo,
    I didn't compile the plugin, I did download an exe and I've installed it. How could I compile it? I'm using Visual Studio 2010.

  • Meanwhile I've discovered, that there is a lacko qt5core.dll and qt5sql..dll. I've copyied them into folder with drivers but now I get exception:
    "Unhandled exception at 0x6659a0fb (Qt5Cored.dll) in test.exe: 0xC0000005: Access violation writing location 0x00000004" while executing QSqlDatabase mydb=QSqlDatabase::addDatabase("QPSQL");
    It occurs in qglobalstatic.h in line: Type *operator()() { if (isDestroyed()) return 0; return innerFunction(); }

  • Lifetime Qt Champion

    "Here": is the building documentation.

    However, there's something fishy in your system, why do you have all these dlls in sysWOW64 ? It's not their place

  • WOW64 because it should be a 32-bit application. I'm using Windows 7 professional 64-bit. Thanks for the link to documentation

  • Lifetime Qt Champion

    Still, it's a system folder, so every application that might use one of these libraries might end up loading these rather that the one that they are shipping and the versions might mismatch thus creating various problem and maybe that's what is hitting you

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.