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 840 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.
  • C Christian Ehrlicher
    3 Feb 2020, 19:20

    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 3 Feb 2020, 19:25 last edited by user4592357 2 Mar 2020, 19:25
    #3

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

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 3 Feb 2020, 19:25 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
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 3 Feb 2020, 19:28 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 3 Feb 2020, 19:29
        1
        • S SGaist
          3 Feb 2020, 19:28

          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 3 Feb 2020, 19:29 last edited by
          #6

          @SGaist
          then what should i be using?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 3 Feb 2020, 19:32 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 3 Feb 2020, 19:33
            0
            • S SGaist
              3 Feb 2020, 19:32

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

              U Offline
              U Offline
              user4592357
              wrote on 3 Feb 2020, 19:33 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
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 3 Feb 2020, 19:40 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 3 Feb 2020, 19:43
                0
                • S SGaist
                  3 Feb 2020, 19:40

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

                  U Offline
                  U Offline
                  user4592357
                  wrote on 3 Feb 2020, 19:43 last edited by user4592357 2 Mar 2020, 19:43
                  #10

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

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 3 Feb 2020, 19:44 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 4 Feb 2020, 06:54 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

                      12/12

                      4 Feb 2020, 06:54

                      • Login

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