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. Set QSqlDatabase driver for already created QSqlQuery. How?
Forum Updated to NodeBB v4.3 + New Features

Set QSqlDatabase driver for already created QSqlQuery. How?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 303 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.
  • B Offline
    B Offline
    bogong
    wrote on last edited by
    #1

    Hello all!
    Here the creating QSqlQuery within Db-driver inside:

    QSqlQuery Query(DBDriver);
    

    The question is how to setup driver for already existed QSqlQuery object? I found only getting info about current driver in use but not setting it up for existed query object. Something like this:

    QSqlQuery Query();
    Query.setDriver(DBDriver);
    
    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      This is not possible (why and how should this be possible)

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

      B 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        This is not possible (why and how should this be possible)

        B Offline
        B Offline
        bogong
        wrote on last edited by bogong
        #3

        @Christian-Ehrlicher I have few DBs inside of application and there need to be executed one SQL String. And I am seeking solution. One of possible ideas - delivering QSqlQuery object to different DB drivers and execute it, because I don't want to be preparing for each of them SQL Query string.

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

          Pass the correct QSqlQuery to a function which does the binding or pass the database to this function.

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

          B 1 Reply Last reply
          1
          • Christian EhrlicherC Christian Ehrlicher

            Pass the correct QSqlQuery to a function which does the binding or pass the database to this function.

            B Offline
            B Offline
            bogong
            wrote on last edited by
            #5

            @Christian-Ehrlicher Thx for reply. That is the thing - I can pass into function only string, it's already developed before me or I need to refactor half of application backend. I think will open DB object pointer and use in constructing query outside of the function. Issue closed.

            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