Results 1 to 3 of 3

Thread: QSqlQuery identify error type

  1. #1
    Join Date
    Dec 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QSqlQuery identify error type

    I'm using postgresql 9.1.
    When I exec a QSqlQuery

    qsqlQuery.exec("INSERT...

    and there is an error, for example
    "ERROR: duplicate key value violates unique constraint "usertable_name_key"
    DETAIL: Key (name)=(2) already exists.
    QPSQL: Unable to create query"

    the error number return is -1? Is it possible to identify the different error type?
    Thanks
    Teo

  2. #2
    Join Date
    Feb 2010
    Posts
    18
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSqlQuery identify error type

    Quote Originally Posted by matteo.ceruti View Post
    I'm using postgresql 9.1.
    the error number return is -1? Is it possible to identify the different error type?
    QSqlQuery.lastError() returns a QSqlError which should give you all error information.

  3. #3
    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: QSqlQuery identify error type

    You need more information than the rather extensive message you already have?

Similar Threads

  1. qsqlquery insert error
    By fantom in forum Qt Programming
    Replies: 4
    Last Post: 23rd February 2011, 17:15
  2. error with QSqlQuery
    By mmm286 in forum Newbie
    Replies: 5
    Last Post: 26th May 2010, 00:27
  3. QSqlQuery.exec() weird error
    By MarkoSan in forum Qt Programming
    Replies: 3
    Last Post: 25th May 2010, 13:02
  4. Data type error
    By MrShahi in forum Qt Programming
    Replies: 1
    Last Post: 16th July 2008, 14:01
  5. QSqlQuery error
    By skuda in forum Qt Programming
    Replies: 2
    Last Post: 2nd November 2007, 08:43

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.