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. Can't save data with customised SQLRelationalTableModel

Can't save data with customised SQLRelationalTableModel

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 3.8k Views 1 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.
  • J Offline
    J Offline
    Jonathan
    wrote on last edited by
    #1

    I've created a subclass of SQLRelationalTableModel and overridden selectStatement(). This is so that I can modify the select statement to convert integers to dates (I'm using SQLite).

    This works fine, and it appears that I can update the view (QTableView) correctly

    Unfortunately when I call submitAll() on my model I get the error "no such column: startDate) Unable to execute statement".

    The column in question is "employee.startDate". How can I see the SQL statement that will be used to update my database? And how can I then modify it if necessary?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mohsen
      wrote on last edited by
      #2

      I guess the reason is that your object which is achieved data is no longer available. Have you declared it in a private function?

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        Probable this is because your select query creates a new column with the converted date and a column alias, so the original column is missing from the query, or something like that.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fcrochik
          wrote on last edited by
          #4

          Jonathan: this is what I tried to warn you about on your "original thread":http://developer.qt.nokia.com/forums/viewthread/2862/.

          You may want to look into the source for the QSQLRelationTableModel to see how it works. I assume it can get the column name if you a query or may have issues dealing with different data types.

          Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fcrochik
            wrote on last edited by
            #5

            How does you select sql looks like? Have you replaced the start date column with "date(employee.”startDate”) as startDate" ?

            Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

            1 Reply Last reply
            0
            • J Offline
              J Offline
              Jonathan
              wrote on last edited by
              #6

              Thanks fcrochik, you've highlighted my mistake. Originally I just replaced "startDate" with "date(employee."startDate")".

              Replacing it with “date(employee.”startDate”) as startDate” cures the problem.

              1 Reply Last reply
              0
              • F Offline
                F Offline
                fcrochik
                wrote on last edited by
                #7

                [quote author="Jonathan" date="1294216603"]Thanks fcrochik, you've highlighted my mistake. Originally I just replaced "startDate" with "date(employee."startDate")".

                Replacing it with “date(employee.”startDate”) as startDate” cures the problem.[/quote]

                You are welcome. Glad to hear that it worked.

                Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

                1 Reply Last reply
                0

                • Login

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