Results 1 to 3 of 3

Thread: QSqlRelationalTablemodel does not update use wrong column

  1. #1
    Join Date
    Jun 2010
    Posts
    2
    Qt products
    Qt4 Qt Jambi PyQt3 PyQt4
    Platforms
    Windows

    Default QSqlRelationalTablemodel does not update use wrong column

    I use an QTableView and a Qrelationaltablemodel
    Further i use a MYSQL view (so not a table)
    QSqlRelation rel("tablename", "tableid", "name");
    model->setRelation(1,rel);
    When i use a mysql table there is no problem, but with a mysqlview i cannot update
    and i get the message:
    Unable to execute statement:
    "[MySQL][ODBC 5.1 Driver][mysqld-5.1.48-community]Unknown column 'name' in 'where clause'"

    Is there a way to change the Updatequery??

    Kind regards
    Carel

  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: QSqlRelationalTablemodel does not update use wrong column

    I think this is what you mean. When you use:
    Qt Code:
    1. QSqlRelation rel("tablename", "tableid", "name");
    2. model->setRelation(1,rel);
    To copy to clipboard, switch view to plain text mode 
    update through 'model' works, and:
    Qt Code:
    1. QSqlRelation rel("viewname", "tableid", "name");
    2. model->setRelation(1,rel);
    To copy to clipboard, switch view to plain text mode 
    it does not, giving:
    Qt Code:
    1. Unable to execute statement:
    2. "[MySQL][ODBC 5.1 Driver][mysqld-5.1.48-community]Unknown column 'name' in 'where clause'"
    To copy to clipboard, switch view to plain text mode 
    Including the 'name' column in your view would be the obvious thing to do first.

  3. #3
    Join Date
    Jun 2010
    Posts
    2
    Qt products
    Qt4 Qt Jambi PyQt3 PyQt4
    Platforms
    Windows

    Default Re: QSqlRelationalTablemodel does not update use wrong column

    Chris,

    Thank you for your quick replay.
    I had the wrong perception that views always can be updated.
    That seems to be wrong.
    I have now solved my problem by hiding columns and using QHeaderView and changeing columns.

    Thanks
    Carel

Similar Threads

  1. Replies: 2
    Last Post: 29th September 2010, 18:44
  2. Replies: 2
    Last Post: 21st October 2009, 09:13
  3. QSortFilterProxyModel - lessThan sorts wrong column
    By ghorwin in forum Qt Programming
    Replies: 2
    Last Post: 21st July 2008, 10:06
  4. Replies: 1
    Last Post: 7th June 2008, 19:29
  5. Replies: 8
    Last Post: 28th May 2007, 21:32

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.