Results 1 to 4 of 4

Thread: QSqlQuery.exec() weird error

  1. #1
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Question QSqlQuery.exec() weird error

    Hi to all!

    I am trying to acces MySQL database via MySQL Odbc connector. I've setup following code:
    Qt Code:
    1. DataBrowserBaseClass::DataBrowserBaseClass(QWidget *parent,
    2. const QString& strTableNAme,
    3. QSqlDatabase& sourceDb)
    4. : QWidget(parent)
    5. {
    6. createMembers(); // create member objects
    7.  
    8. if(sourceDb.open())
    9. {
    10. // db opened ok
    11. if(queryTablesList()->exec())
    12. {
    13. // query exec ok
    14. while(queryTablesList()->next())
    15. {
    16. tablesList()->append(queryTablesList()->value(0).toString());
    17. } // while
    18. }
    19. else
    20. {
    21. // query exec error, handle it
    22. sourceDb.close(); // closes connection to database
    23. } // if
    24. }
    25. else
    26. {
    27. // db open error handler
    28. }
    29. }
    To copy to clipboard, switch view to plain text mode 
    and I get following error:
    "QODBCResult::exec: No statement handle available" Error: " "
    What does this mean? What am I doing wrong?

    Sincerely,
    Marko
    Qt 5.3 Opensource & Creator 3.1.2

  2. #2
    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: QSqlQuery.exec() weird error

    I would guess one of the functions of yours that you call are incorrect.
    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
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QSqlQuery.exec() weird error

    Well, how can I then get list of tables inside database? I did this:
    Qt Code:
    1. m_pQueryTablesList=new QSqlQuery("SHOW TABLES",
    2. sourceDb);
    3. Q_ASSERT_X(queryTablesList()!=0,
    4. "Table list query allocation",
    5. "Table list query could not be allocated.");
    To copy to clipboard, switch view to plain text mode 
    If I enter identical command into MySQL command line, I get list ok.
    Qt 5.3 Opensource & Creator 3.1.2

  4. #4
    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: QSqlQuery.exec() weird error

    Please provide a minimal compilable example reproducing the problem. Please also remember you are using ODBC to access the database not the native MySQL driver for Qt.
    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. Abort QSqlQuery::exec()
    By elmo in forum Qt Programming
    Replies: 5
    Last Post: 13th October 2013, 20:50
  2. QSqlQuery and no response while exec()
    By jacek_ in forum Qt Programming
    Replies: 5
    Last Post: 5th November 2009, 08:47
  3. QSqlQuery::exec: database not open
    By newtowindows in forum Qt Programming
    Replies: 8
    Last Post: 29th October 2009, 08:48
  4. Weird compile error
    By MarkoSan in forum Qt Programming
    Replies: 6
    Last Post: 3rd December 2007, 18:50
  5. weird error
    By mickey in forum General Programming
    Replies: 6
    Last Post: 18th November 2006, 04: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.