Results 1 to 8 of 8

Thread: QSqlRelationalTableModel and SubmitAll()

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    75
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default

    Maybe that's the problem, the tables have int non-null columns named "id" but they aren't actually set as primary keys in the tables themselves. Do you think that is the problem?

    Oh and each table has a column named "id".

    I've got a related question: Is there a way for me to be able to view the sql statement that was internally built? If I could see that, it might help me understand this a bit better.
    Last edited by wysota; 22nd January 2008 at 15:47. Reason: Posts merged

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

    Default Re: QSqlRelationalTableModel and SubmitAll()

    Quote Originally Posted by kroenecker View Post
    Maybe that's the problem, the tables have int non-null columns named "id" but they aren't actually set as primary keys in the tables themselves. Do you think that is the problem?
    That's the first thing I would check. The problem you are facing is surely related to the database and not to Qt itself.

    I've got a related question: Is there a way for me to be able to view the sql statement that was internally built? If I could see that, it might help me understand this a bit better.
    Yes, of course. The relational model inherits table model which in turn inherits QSqlQueryModel. So for peeking the select statement you have two choices - either through QSqlQueryModel::query() or QSqlTableModel::selectStatement(). QSqlTableModel::setPrimaryKey(), QSqlTableModel::primaryKey() are also worth having a look at. If you want to inspect the update query, you'll probably have to peek the query log of your SQL server or use QSqlQuery::lastQuery().

Similar Threads

  1. QSqlTableModel submitAll access query
    By patrik08 in forum Qt Programming
    Replies: 4
    Last Post: 27th April 2007, 08:04
  2. submitAll() : database error
    By locus in forum Qt Programming
    Replies: 3
    Last Post: 27th January 2007, 05:49

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
  •  
Qt is a trademark of The Qt Company.