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. QT MySQL Databese connect fail
Forum Updated to NodeBB v4.3 + New Features

QT MySQL Databese connect fail

Scheduled Pinned Locked Moved Solved General and Desktop
mysqldatabaseqt5.9.2c++localhost
4 Posts 2 Posters 693 Views
  • 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.
  • E Offline
    E Offline
    ELEMENTICY
    wrote on 9 Mar 2021, 04:31 last edited by
    #1

    Hello i got 11 error on connecting to sql server
    Please help
    this is my code

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
        db.setHostName("localhost");
        db.setDatabaseName("mysql");
        db.setUserName("root");
        db.setPassword("rootPW");
        bool connected = db.open();
    

    and this is the error
    Capture.PNG
    i dont know why is this happening,please help me.Thanks

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 9 Mar 2021, 05:14 last edited by
      #3

      You forgot to link against the QtSql library.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      E 1 Reply Last reply 9 Mar 2021, 05:22
      2
      • E Offline
        E Offline
        ELEMENTICY
        wrote on 9 Mar 2021, 05:00 last edited by
        #2

        oops,sorry.My version of qt is 6.0.1

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 9 Mar 2021, 05:14 last edited by
          #3

          You forgot to link against the QtSql library.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          E 1 Reply Last reply 9 Mar 2021, 05:22
          2
          • C Christian Ehrlicher
            9 Mar 2021, 05:14

            You forgot to link against the QtSql library.

            E Offline
            E Offline
            ELEMENTICY
            wrote on 9 Mar 2021, 05:22 last edited by
            #4

            @Christian-Ehrlicher yes,i just realize i forget to add sql to QT += core gui sql
            thanks for respone anyway

            1 Reply Last reply
            0

            1/4

            9 Mar 2021, 04:31

            • Login

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