Results 1 to 2 of 2

Thread: Closing correctly sqlite connection?

  1. #1
    Join Date
    May 2009
    Posts
    21
    Thanks
    11
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Closing correctly sqlite connection?

    Hi,
    I want to delete a sqlite database, on linux and mac i have no problems, but in windows i can't delete the sql file because "It is in use". So my question is, how do you close in the right way the database?

    Is this wrong?

    Qt Code:
    1. db->close();
    2. db->removeDatabase("QSQLITE");
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Closing correctly sqlite connection?

    QSqlDatabase::removeDatabase() is static so call:
    Qt Code:
    1. {
    2. db.setDatabaseName("somename");
    3. //...
    4. db->close();
    5. }
    6. QSqlDatabase::removeDatabase("somename");
    To copy to clipboard, switch view to plain text mode 

  3. The following 2 users say thank you to Lykurg for this useful post:

    0xl33t (9th August 2009), miwarre (13th November 2009)

Similar Threads

  1. How can I send a SQLite :memory: database connection ?
    By georgep in forum Qt Programming
    Replies: 4
    Last Post: 20th July 2009, 12:07
  2. QT - SQLite Connection
    By sabeesh in forum Qt Programming
    Replies: 14
    Last Post: 3rd June 2009, 13:58
  3. Client/Server Error: BadIDChoice
    By 3nc31 in forum Qt Programming
    Replies: 5
    Last Post: 27th November 2007, 10:22

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.