Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSqlTableModel with SQLITE and MySQL
Qt 6.11 is out! See what's new in the release blog

QSqlTableModel with SQLITE and MySQL

Scheduled Pinned Locked Moved Solved General and Desktop
sqlqsqltablemodel
6 Posts 3 Posters 3.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hrompato
    wrote on last edited by SGaist
    #1

    I have a QSqlTableModel associated with a database (SQLite or QMYSQL). When performing sumbitAll a 'false "response it is generated, but QSqlError :: NativeErrorCode () returns an empty string and QSqlError :: text () returns a space
    However, the data is read and the table is displayed.

    Someone has happened to him something?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you sure that the database is opened correctly ? What request are you dong before submitAll ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      H 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Are you sure that the database is opened correctly ? What request are you dong before submitAll ?

        H Offline
        H Offline
        hrompato
        wrote on last edited by
        #3

        Thanks @SGaist, The database is open and is correctly displayed on a tableview

        Try to work with two databases simultaneously, maybe that's the error

        Curiously:

        QSqlDatabase db = model->database();
        if (db.isValid())
            qDebug() << "Is valid";
        if (db.isOpen())
            qDebug() << "Is open";
        

        shows that db is valid but is closed (but I opened to read data)

        I'll recheck my code now.

        the_T 1 Reply Last reply
        0
        • H hrompato

          Thanks @SGaist, The database is open and is correctly displayed on a tableview

          Try to work with two databases simultaneously, maybe that's the error

          Curiously:

          QSqlDatabase db = model->database();
          if (db.isValid())
              qDebug() << "Is valid";
          if (db.isOpen())
              qDebug() << "Is open";
          

          shows that db is valid but is closed (but I opened to read data)

          I'll recheck my code now.

          the_T Offline
          the_T Offline
          the_
          wrote on last edited by
          #4

          @hrompato

          What does db.lastError(); return after trying to open the database?

          -- No support in PM --

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hrompato
            wrote on last edited by
            #5

            My fault!, had closed the database previously :-(

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              That might happen ;)

              By the way, no need to modify the title anymore. You can use the topic tool button to mark the thread as solved :)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved