加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-12 20:21:11 所属栏目:百科 来源:网络整理
导读: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: Switch view void MainWindow :: odczytajBazeSQL ( ) { Q
  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: Switch view
              
              
    1. void MainWindow :: odczytajBazeSQL ( )
    2. {
    3. QSqlDatabase addDatabase ( "QSQLITE" );
    4. QSqlDatabase bdb;
    5. bdb. setDatabaseName "/test.db" );
    6. bdb. open );
    7. QSqlQueryModel *queryModel = new QSqlQueryModel;
    8. queryModel ->setQuery "SELECT * FROM t1",bdb );
    9. ui ->tableView ->setModel (queryModel );
    10. }
    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: Switch view
              
              
    1. : QSQLITE driver not loaded
    2. : available drivers :
    3. QSqlQuery exec : database not open

    Normally I'm using sqlite3 to create and use databases. What should I do to make it work?

    thanks in advance
    best regards
    Tomasz
    Reply With Quote
  2. #2 wysota 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.

    Reply With Quote
  3. The following user says thank you to wysota for this useful post:

    Tomasz(21st July 2010)
  4. 10:22 #3 Tomasz 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: Switch view
    QSqlDatabase bdb 
                 = 
                 ); 
                
  5. bdb. "./test.db" );
  6. ok = bdb. );

and now It works fine,

best regards
Tomasz
Last edited by Tomasz; 21st July 2010 at 10:30.
Reply With Quote
  • 10:28 #4 wysota Master of Zen Re: QT & SQLite - driver not loaded
    Change your code to:
    Qt Code: Switch view
     
        Reply With Quote 
         
        
       
  • The following user says thank you to wysota for this useful post:
    Tomasz(21st July 2010)
  • #5 sadjoker 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.
  • (编辑:李大同)

    【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

      推荐文章
        热点阅读