Results 1 to 5 of 5

Thread: Why sqlite db address not working at all?

  1. #1
    Join Date
    Nov 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy Why sqlite db address not working at all?

    Hi
    I'm using sqlite with Qt library
    Qt Code:
    1. #include <QtSql/QSqlDatabase>
    2. #include <QSqlQuery>
    To copy to clipboard, switch view to plain text mode 
    this is my code for connection :
    Qt Code:
    1. QSqlDatabase mydb = QSqlDatabase::addDatabase("QSQLITE");
    2. mydb.setDatabaseName(QCoreApplication::applicationDirPath() + "/data/27115");
    3. mydb.open();
    4. QSqlQuery query("SELECT * FROM setting");
    5. if (mydb.open())
    6. {
    7. query.exec();
    8. int fieldNo = query.record().indexOf("theme");
    9. while (query.next()) {
    10. ui->cmb_themes->addItem(query.value(fieldNo).toString());
    11. }
    12. }
    13. mydb.close();
    To copy to clipboard, switch view to plain text mode 

    Now in my system,its work right without any problem,but i copied debug folder in other computer and run, my application cant find db file!!

    in other system i installed qt sdk and open myapp.pro on it,and run.. next .. db file could run and worked.why?
    in my laptop with Windows7 64 bits , output address is : '.....'-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug

    and in other computer with windows 7 32 bits , output address is : '.....'-build-desktop

    thanks before answer

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Why sqlite db address not working at all?

    Did you deploy the sqlite driver to the other machine?
    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.


  3. #3
    Join Date
    Nov 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Why sqlite db address not working at all?

    No.i'm using it direct(with db file address)
    how can i?
    if deploy sqlite,it can works?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Why sqlite db address not working at all?

    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.


  5. #5
    Join Date
    Nov 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Why sqlite db address not working at all?

    oh yes.very good answer
    so thanks

Similar Threads

  1. QT + Sqlite not working
    By BrainStorm in forum Qt Programming
    Replies: 3
    Last Post: 11th August 2010, 02:52
  2. [Qt][SQLite] Two problems with SQLite.
    By Xandareva in forum Newbie
    Replies: 6
    Last Post: 7th April 2010, 00:06
  3. OUT OF MEMORY - Error while working with sqlite
    By Askar in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2009, 00:54
  4. how can i get IP address
    By dognzhe in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2009, 06:27
  5. working with SQLite
    By bhs-ittech in forum Qt Programming
    Replies: 3
    Last Post: 15th September 2008, 08:51

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
  •  
Qt is a trademark of The Qt Company.