Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] QT & MySQL - What must be done? [Beginner]
Forum Updated to NodeBB v4.3 + New Features

[Solved] QT & MySQL - What must be done? [Beginner]

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kaivolde
    wrote on last edited by
    #1

    Hi folks,

    I want to start accessing a MySQL-DB programatically with Qt.

    The basic question is - what do I have to do?

    Here is my setup:
    qt-opensource-windows-x86-msvc2013_64_opengl-5.3.1
    Windows8.1 64bit
    Visual Studio 2013 Express
    MySQL (I installed nearly everything, connectors, etc, the main version is 5.6 (I think))

    In the Qt-directory plugins/sqldrivers there are already the two files qsqlmysql.dll and qsqlmysqld.dll

    The methodcall QSqlDatabase::isDriverAvailable( "QMYSQL" ) gives me a "true".

    But a call to QSqlDatabase::addDatabase( "QMYSQL" )
    gives the warnings:
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

    So I think the driver is there but it can't be loaded. What is wrong? Do I have to compile some additional things?

    Many thanks in advance.

    Best regards
    Kai

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You need to have the path to the mysql dlls in your PATH environment variable. You can add it in the run part of the Project panel

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kaivolde
        wrote on last edited by
        #3

        Works - perfect!

        To be a little bit more precise for people who will run into the same problem. On my sytem I had to expand the PATH variable with the following path:
        C:\Program Files\MySQL\MySQL Server 5.6\lib

        Thanks SGaist

        BTW: I did not find this essential hint in the current Qt-docs. Is there a way to add it there?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You have the Troubleshooting section of the "SQL Database Driver" chapter in the documentation but it might use that information.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            marcnnn
            wrote on last edited by
            #5

            sorry got the same problem but i am not able to fix it...

            got qt 5.3 mingw 32 on 64 bit win 7
            mysql 5.6 dev install

            on linux every thing is fine but Win :(

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kaivolde
              wrote on last edited by
              #6

              Hi,
              I guess the problem you encounter now is that the libraries of the downloaded MySQL-distribution are for VisualStudio (not MinGW).

              So you must try to fetch the MinGW-libs.

              Regards
              Kai

              1 Reply Last reply
              0
              • M Offline
                M Offline
                marcnnn
                wrote on last edited by
                #7

                how i change to msvs but still got trouble... can't compline driver ...

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  It's a bit vague, what errors are you getting ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved