Results 1 to 3 of 3

Thread: database open returns false

  1. #1
    Join Date
    Mar 2011
    Posts
    23
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default database open returns false

    I create a QSqlDatabase object an then I open it.

    Qt Code:
    1. db=QSqlDatabase::addDatabase("qwe.db");
    2. db.open();
    To copy to clipboard, switch view to plain text mode 

    after that isOpen() and isValid() return true.

    After that when I want to connect database I wote this:

    Qt Code:
    1. if(!db.isOpen()) -->returns false. but I never close db until app closing
    2. {
    3. db.open(); -->it returns false
    4. }
    To copy to clipboard, switch view to plain text mode 

    after that isOpen() and isValid() return false;
    But my queries work and I can get data from database.

    What is wrong here?
    Last edited by ahmetturan; 21st January 2014 at 12:32.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: database open returns false

    Quote Originally Posted by ahmetturan View Post
    I create a QSqlDatabase object an then I open it.

    Qt Code:
    1. db=QSqlDatabase::addDatabase("qwe.db");
    2. db.open();
    To copy to clipboard, switch view to plain text mode 

    after that isOpen() and isValid() return true.
    I doubt they do.
    What is wrong here?
    You are misusing QSqlDatabase::addDatabase(). I suggest you read the Detailed Description again.

  3. #3
    Join Date
    Mar 2011
    Posts
    23
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: database open returns false

    I am sorry @ChrisW67. I copy-paste wrongly.
    My code:

    Qt Code:
    1. db=QSqlDatabase::addDatabase("QSQLITE");
    2. db.setDatabaseName("qwe.db");
    3. db.open();
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. qpixmap.save() returns false
    By Charvi in forum Qt Programming
    Replies: 3
    Last Post: 2nd July 2012, 07:10
  2. QSqlQueryModel insertColumn() returns false
    By kasper360 in forum Newbie
    Replies: 2
    Last Post: 28th March 2011, 04:58
  3. QSslSocke::supportSsl() returns false
    By oscar in forum Qt Programming
    Replies: 1
    Last Post: 9th September 2008, 18:51
  4. QSqlQuery::isValid returns false
    By mismael85 in forum Qt Programming
    Replies: 24
    Last Post: 7th September 2008, 23:43
  5. connect returns false
    By krivenok in forum Qt Programming
    Replies: 6
    Last Post: 21st February 2006, 20:01

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.