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
QtWS25 Last Chance

QT MySQL Databese connect fail

Scheduled Pinned Locked Moved Solved General and Desktop
mysqldatabaseqt5.9.2c++localhost
4 Posts 2 Posters 654 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 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
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 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
      2
      • E Offline
        E Offline
        ELEMENTICY
        wrote on last edited by
        #2

        oops,sorry.My version of qt is 6.0.1

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 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
          2
          • Christian EhrlicherC Christian Ehrlicher

            You forgot to link against the QtSql library.

            E Offline
            E Offline
            ELEMENTICY
            wrote on 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

            • Login

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