QT & SQLite - driver not loaded[Win7 XP mode failed too]

前端之家收集整理的这篇文章主要介绍了QT & SQLite - driver not loaded[Win7 XP mode failed too]前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. http://www.qtcentre.org/threads/32585-QT-amp-sqlite-driver-not-loaded

    QT & sqlite - driver not loaded

    Hello!

    I'm trying to read from sqlite database. I've wrote simple function:

    Qt Code:
              
              
    1. void MainWindow :: odczytajBazesql ( )
    2. {
    3. QSqlDatabase addDatabase ( "QsqlITE" );
    4. bdb. setDatabaseName "/test.db" );
    5. bdb. open );
    6. QSqlQueryModel *queryModel = new QSqlQueryModel;
    7. queryModel ->setQuery "SELECT * FROM t1",bdb );
    8. ui ->tableView ->setModel (queryModel );
    9. }
    To copy to clipboard,switch view to plain text mode

    test.db is a simple database with one table t1. When I'm trying to read with code above I get error:

    Qt Code:
              
              
    1. QSqlQuery exec : database not open
    sqlite3 to create and use databases. What should I do to make it work?

    thanks in advance
    best regards
    Tomasz
  2. #2
    Master of Zen
    Join Date
    Jan 2006
    Location
    Warsaw,Poland
    Posts
    28,434
    Thanks
    3
    Thanked 4,110 Times in 3,960 Posts
    Qt products
    Platforms
    Blog Entries
    4
    Wiki edits
    10
    Re: QT & sqlite - driver not loaded
    QsqlDatabase: available drivers:
    You don't seem to have any Qt sql drivers installed. Maybe you need to install some additional packages for your distribution.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.

  • The following user says thank you to wysota for this useful post:

    Tomasz(21st July 2010)
  • 10:22 #3
  • Intermediate user
    Join Date
    Jul 2010
    Location
    Poland
    Posts
    184
    Thanks
    70
    Thanked 4 Times in 4 Posts
    Qt products
    Platforms
    Re: QT & sqlite - driver not loaded
    I've copied compilled driver (it wasn't there),I've change my code to:

    Qt Code:
    QsqlDatabase bdb 
                 = 
                 ); 
                
  • bdb. "./test.db" );
  • ok = bdb. );
  • Last edited by Tomasz; 21st July 2010 at 10:30.
  • 10:28 #4
  • Master of Zen
    Re: QT & sqlite - driver not loaded
    Change your code to:
  • The following user says thank you to wysota for this useful post:
    Tomasz(21st July 2010)
  • #5
  • Novice
    Join Date
    Feb 2008
    Posts
    50
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Platforms

    Re: QT & sqlite - driver not loaded

    Hello all. As we are speaking about sqlITE driver i had a very stressful experience with that driver (4.6.2/4.6.3). I deployed over 100 copies of one program using latest sqlite driver. There was no problem anywhere... i put the dll file under the executable file in directory "sqldrivers".
    Only in some particular systems this new driver wasn`t loading... i was like O_o. I`m talking about 2% of all the systems.
    I`ve spent a lot of hours debugging remotely the machines and didn`t find a way to make it work. But i knew my old software worked on those machines before... then i switched to a sqlite dll from 4.4.0 and .. magically the driver was loaded!
    Apparently something in the driver changed but i couldn`t find time to investigate further.

    Edit: the machines were WinXP Pro SP3.
    Last edited by sadjoker; 22nd July 2010 at 18:23.

    猜你在找的Sqlite相关文章