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. Help MySql Database not open

Help MySql Database not open

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.6k 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.
  • R Offline
    R Offline
    ReDKiiL
    wrote on last edited by
    #1

    Hey, i need help to solve this.

    !http://i.imgur.com/5Ve1AdV.png(http://i.imgur.com/5Ve1AdV.png)!

    Error: QSqlQuery::prepare: database not open

    Thanks to all who help.

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

      Hi,

      Check that the open call was successfull and if not at least print the error message you got

      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
      • R Offline
        R Offline
        ReDKiiL
        wrote on last edited by
        #3

        SGaist, /.

        http://i.imgur.com/alXa8Sa.png

        I can't understand what's happening;

        #SOLVED

        I changed:
        @db = QSqlDatabase::addDatabase("QMYSQL","one");@
        to:

        @db = QSqlDatabase::addDatabase("QMYSQL");@

        SGaist, ty for reply :)

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

          You're welcome !

          If you name your connection then when creating e.g. QSqlQuery objects you also need to tell it which database connection you want to use

          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
          • jerome_isAviableJ Offline
            jerome_isAviableJ Offline
            jerome_isAviable
            wrote on last edited by
            #5

            if you give a name to your database connection, so like Sgaist tell you, you need at open time to tell him to open this one (in your code, name was "one".
            Then, if you naot give a name to the connection, this opening is for general use. It is a way to play with many different database connections...

            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