Results 1 to 6 of 6

Thread: QSqlDatabase close method error in DEBUG mode

  1. #1
    Join Date
    Jun 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default QSqlDatabase close method error in DEBUG mode

    Hello to everyone.

    I'm stuck on an error from QSqlDatabase.

    I'm modifying a project wrote by other developers.

    Last working configuration was VC6 with QT4 library and everything worked, but when I try to port it to Qt creator using QT4 library i got an "unknown error" message from QT.

    The error occurs when I try to call QSqlDatabase close method:


    Qt Code:
    1. DB_MSAccess::DB_getProductInfo()
    2. {
    3. openclose = m_RegisterDB.open(); // openclose return true, so the database is open
    4. m_RegisterDB.close();
    5. }
    To copy to clipboard, switch view to plain text mode 


    The QSqlDatabase is initialized in the constructor class and is declared private into header file.
    Qt Code:
    1. DB_MSAccess::DB_MSAccess()
    2.  
    3. {
    4. m_RegisterDB= QSqlDatabase::addDatabase("QODBC",MAIN_DB);
    5. m_RegisterDB.setDatabaseName (MAIN_DB);
    6. }
    To copy to clipboard, switch view to plain text mode 


    I forget to mention that the error occurs only in DEBUG -step by step mode. If I run the code either in RELEASE or DEBUG the code works perfectly.

    Anyone knows how to help me??

    Thanks for your help

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSqlDatabase close method error in DEBUG mode

    You might like to point people to some discussion that you have already started on this. Just so you don't waste time re-hashing old ground.


    http://www.qtforum.org/article/38055...ebug-mode.html
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Jun 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: QSqlDatabase close method error in DEBUG mode

    Hi amleto,
    thanks for your reply.

    You might like to point people to some discussion that you have already started on this. Just so you don't waste time re-hashing old ground.


    http://www.qtforum.org/article/38055...ebug-mode.html

    Maybe you are right and I should have report the link to the other post.


    Please tell me what do you mean about complete code. Below there are the two main class related to this error.

    This is the DB_MSAccess class that inherits from DB_Interface:
    Qt Code:
    1. class DB_MSAccess: public DB_Interface
    2. {
    3. public:
    4.  
    5. DB_MSAccess();
    6. ~DB_MSAccess();
    7.  
    8. quint16 getProdList(QString Id, QStringList* prodList);
    9.  
    10.  
    11. protected:
    12.  
    13.  
    14. private:
    15. QSqlDatabase m_RegisterDB;
    16.  
    17. }
    To copy to clipboard, switch view to plain text mode 
    and the DB_Interface class is reported below (It contains only one virtual method):
    Qt Code:
    1. class DB_Interface
    2. {
    3. public:
    4. DB_Interface();
    5.  
    6. virtual quint16 getProdList(QString Id, QStringList* prodList);
    7. }
    To copy to clipboard, switch view to plain text mode 
    I use the Qt Creator 2.3.0 and Qt 4.7.4 library.

    Hope this can help you to help me

  4. #4
    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: QSqlDatabase close method error in DEBUG mode

    There are no obvious errors in the code you have given us. I gather from the other thread that the error message is actually a Qt Creator error dialog (I cannot see the screen shot) and not output from this program. The observation that you do not get the message at all if you just run the program rather than running it in a debugger points at an issue with debugging not the program.. So, the issue looks like an interaction between your debugger and Qt Creator.

    Try running the program in your debugger outside of Qt Creator. Any odd error messages from the debugger?
    Which debugger? Which compiler?
    Last edited by ChrisW67; 7th June 2012 at 03:39.

  5. #5
    Join Date
    Jun 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSqlDatabase close method error in DEBUG mode

    Hi ChrisW67,
    I use Qt Debugger vers. 2.3.0. The compiler is MinGW 4.4.0.
    Try running the program in your debugger outside of Qt Creator. Any odd error messages from the debugger?
    Which debugger? Which compiler?
    What do you mean by "running the program outside Qt creator"? I don't know how do it. Could you explain me how do it please?

    Thanks

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

    Default Re: QSqlDatabase close method error in DEBUG mode

    Open command line, run gdb passing it the path to your executable, then type "run" and see what happens. If you want to step through the program this way then I suggest you read some tutorial on using gdb.
    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.


Similar Threads

  1. Replies: 1
    Last Post: 7th March 2012, 22:34
  2. Replies: 2
    Last Post: 21st August 2010, 11:26
  3. Replies: 1
    Last Post: 2nd November 2009, 13:02
  4. Replies: 9
    Last Post: 15th April 2009, 07:23
  5. Error compiling Qt 4.0 in Debug mode
    By Doug Broadwell in forum Installation and Deployment
    Replies: 1
    Last Post: 11th October 2006, 09:15

Tags for this Thread

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.