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. getting already open database connection
Forum Updated to NodeBB v4.3 + New Features

getting already open database connection

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 3 Posters 759 Views 2 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.
  • Christian EhrlicherC Christian Ehrlicher

    Don't think this has something to do with the other database connection. I would take a look at the query where it fails, and check what QSqlQuery::error() and database() really returns.

    U Offline
    U Offline
    user4592357
    wrote on last edited by user4592357
    #3

    @Christian-Ehrlicher
    the error is from QSqlQuery::lastError().
    and it worked with default connection

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #4

      Please show the query, make sure that the db is really open at the time you're trying to execute the query.

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

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

        Hi,

        To add to @Christian-Ehrlicher, I am not sure that using a file path is necessarily a good idea for a connection name.

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

        U 1 Reply Last reply
        1
        • SGaistS SGaist

          Hi,

          To add to @Christian-Ehrlicher, I am not sure that using a file path is necessarily a good idea for a connection name.

          U Offline
          U Offline
          user4592357
          wrote on last edited by
          #6

          @SGaist
          then what should i be using?

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

            A meaningful identifier, just the name of the database, etc. That's up to you.

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

            U 1 Reply Last reply
            0
            • SGaistS SGaist

              A meaningful identifier, just the name of the database, etc. That's up to you.

              U Offline
              U Offline
              user4592357
              wrote on last edited by
              #8

              @SGaist
              yeah something unique, so i thought file path would be more unique then fine name

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

                In any case, you should do as @Christian-Ehrlicher wrote: get the error from the failed query.

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

                U 1 Reply Last reply
                0
                • SGaistS SGaist

                  In any case, you should do as @Christian-Ehrlicher wrote: get the error from the failed query.

                  U Offline
                  U Offline
                  user4592357
                  wrote on last edited by user4592357
                  #10

                  @SGaist
                  the parameter mismatch error is the text given by lastError()

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

                    And what is the query ? The one returned by lastQuery ?

                    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
                    • U Offline
                      U Offline
                      user4592357
                      wrote on last edited by
                      #12

                      actually prepare() was failing and i got the error from sql query at right after prepare() and it was meaningful

                      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