Results 1 to 2 of 2

Thread: Two database connections with different drivers at the same time?

  1. #1
    Join Date
    Nov 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Two database connections with different drivers at the same time?

    Hello!
    I try to establish two database connections, one with PostgreSQL and second with SQLite. I start with code:
    Qt Code:
    1. QSqlDatabase mainDatabase = QSqlDatabase::addDatabase("QPSQL", "MainDatabase");
    2. QSqlDatabase mapDatabase = QSqlDatabase::addDatabase("QSQLITE", "MapDatabase");
    To copy to clipboard, switch view to plain text mode 
    then I setup and test connection with PostgreSQL – everything its fine so far. When I try to open SQLite databse with code:
    Qt Code:
    1. mapDatabase.setDatabaseName("db_name");
    2. if (!this->mapTilesDatabase.open())
    3. {
    4. // error handling
    5. }
    To copy to clipboard, switch view to plain text mode 
    I recieve error: Driver not loaded.
    Is it possible to use two different database divers simultaneously at all?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,595
    Thanks
    13
    Thanked 1,588 Times in 1,517 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Two database connections with different drivers at the same time?

    Is it possible to use two different database divers simultaneously at all?
    Yes. I have done so with ODBC and Sqlite. I am sure others have done your particular combination.
    I recieve error: Driver not loaded.
    Have you deployed the Sqlite plugin with your application?
    Is it showing in the output of QSqlDatabase::drivers()?

Similar Threads

  1. how to install DataBase Drivers
    By un9tsandeep in forum Qt Programming
    Replies: 2
    Last Post: 4th October 2011, 12:44
  2. LGPL and distributing QT database drivers
    By BitRogue in forum General Discussion
    Replies: 4
    Last Post: 7th July 2011, 09:32
  3. Database drivers provided with Qt Open Source Edition
    By babygal in forum Qt Programming
    Replies: 1
    Last Post: 17th August 2010, 07:47
  4. database drivers - installation
    By banita in forum Qt Programming
    Replies: 5
    Last Post: 29th April 2010, 19:26
  5. Issues regarding QMySql drivers and mysql database
    By bera82 in forum Qt Programming
    Replies: 2
    Last Post: 10th August 2006, 17:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.