Results 1 to 20 of 25

Thread: Releasing database file with QSqlDatabase

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default Releasing database file with QSqlDatabase

    Hi

    I am struggling to release a database file I use with QSqlDatabase. I need the ability to close the connection and then delete the database file before replacing it with a new database. I can't delete it because the my program is holding onto it. I create my connection using the code below and dbProject is define globally for now.

    Qt Code:
    1. bool createDBConnection() {
    2. if (QSqlDatabase::connectionNames().isEmpty()) {
    3. dbProject = QSqlDatabase::addDatabase("QSQLITE");
    4. }
    5. dbProject.setDatabaseName(active_db_file);
    6. if (!dbProject.open()) {
    7. // Error messages
    8. }
    9. return dbProject.isValid();
    10. }
    To copy to clipboard, switch view to plain text mode 

    To release the file I am trying:
    Qt Code:
    1. dbProject.close();
    To copy to clipboard, switch view to plain text mode 

    According to the QT docs it seems like this should be good enough. Does anybody know why it does not work?

    Thanks
    Jaco
    Last edited by jpn; 19th August 2008 at 12:07. Reason: missing [code] tags

Similar Threads

  1. Multiple database connections
    By cyberboy in forum Qt Programming
    Replies: 3
    Last Post: 30th March 2008, 16:56
  2. Set up the Qt4.3.2 with Visual Studio 2005
    By lamoda in forum Installation and Deployment
    Replies: 6
    Last Post: 30th January 2008, 06:51
  3. Database: How to use an external file?
    By goes2bob in forum Newbie
    Replies: 10
    Last Post: 23rd January 2008, 14:07
  4. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21

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.