Results 1 to 20 of 57

Thread: Record update windowd entered data saving

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Default Re: Record update windowd entered data saving

    God damn, I tried both setValue versions, I took a look at sql statement, which executes, all without errors (QSqlError returns NoError). insertRecord statement returns TRUE (which is by the docs OK), but data are still not visible. Any other idea??
    Qt 5.3 Opensource & Creator 3.1.2

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

    Default Re: Record update windowd entered data saving

    Are they inserted into the database and not visible in the application or not inserted at all? What happens if you execute the same query "by hand"?

  3. #3
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Default Re: Record update windowd entered data saving

    Well, i got the statement:
    Qt Code:
    1. QSqlQuery::lastQuery returned {"SELECT stranka.SIFRA,stranka.DS,stranka.PRIIMEK,stranka.IME,ulica.naziv,stranka.STEVILKA_ULICE,kraj.naziv_kraja FROM stranka,u" size=217}
    To copy to clipboard, switch view to plain text mode 

    from the code:
    Qt Code:
    1. QSqlRecord cDataRecord;
    2.  
    3. cDataRecord.setValue(QString("SIFRA"), m_pUpdateWindow->GetCustomerID()->text());
    4. cDataRecord.setValue(QString("DS"), m_pUpdateWindow->GetTaxNumber()->text());
    5. cDataRecord.setValue(QString("PRIIMEK"), m_pUpdateWindow->GetSurname()->text());
    6. cDataRecord.setValue(QString("IME"), m_pUpdateWindow->GetName()->text());
    7. //cDataRecord.setValue("ULICA", m_pUpdateWindow->GetStreetID()->text());
    8. cDataRecord.setValue(QString("STEVILKA_ULICE"), m_pUpdateWindow->GetStreetNumber()->text());
    9. cDataRecord.setValue(QString("POSTA_STEVILKA"), m_pUpdateWindow->GetZipCode()->text());
    10. if(m_pTableModel->insertRecord(INSERT_RECORD_AT_END, cDataRecord))
    11. {
    12. QSqlError error=m_pTableModel->lastError();
    13. if(error.type()!=QSqlError::NoError)
    14. {
    15. qDebug() << m_pTableModel->query().lastQuery();
    16. } // if
    17. } // if
    To copy to clipboard, switch view to plain text mode 

    There is no INSERT statement at all, what the heck is going on??
    Qt 5.3 Opensource & Creator 3.1.2

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

    Default Re: Record update windowd entered data saving

    Try calling submit() or submitAll() on the model.

  5. #5
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Default Re: Record update windowd entered data saving

    Same result, empty record added to table, when I reopen the window, this empty record is not shown, so I neither does add empty neither filled record to database. Is maybe problem in QSqlDelegate?
    Last edited by MarkoSan; 6th January 2006 at 08:59.
    Qt 5.3 Opensource & Creator 3.1.2

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Record update windowd entered data saving

    Maybe the problem is with MySQL 5.0?

    Did you try debugging to see if Qt even tries to fill those fields?

  7. #7
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Default Re: Record update windowd entered data saving

    As i posted earlier, I think the statement:
    QSqlQuery::lastQuery returned "SELECT stranka.SIFRA,stranka.DS,stranka.PRIIMEK,stranka.I ME,ulica.naziv,stranka.STEVILKA_ULICE,kraj.naziv_k raja FROM stranka,u"size=217
    ,which is created in method insertRecord is not correct.

    Since I am total newbie in SQL, am I right or not?

    It seems, but it is not logical, that method insertRecord does not create an SQL statment, but it should, as I understand the whole thing.

    Or maybe, in the docs there is definition of method:
    Qt Code:
    1. bool QSqlTableModel::insertRecord ( int [I]row[/I], const [URL="http://www.qtcentre.org/forum/qsqlrecord.html"][COLOR=#0000ff][U]QSqlRecord[/U][/COLOR][/URL] & [I]record[/I] )
    To copy to clipboard, switch view to plain text mode 
    The statement in my project is:
    Qt Code:
    1. if(m_pTableModel->insertRecord(INSERT_RECORD_AT_END, cDataRecord))
    To copy to clipboard, switch view to plain text mode 
    cDataRecord is declared as:
    Qt Code:
    1. QSqlRecord cDataRecord;
    To copy to clipboard, switch view to plain text mode 
    As far as I can see, the second parameter is reference to sql record, but i pass like insertRecord(-1, cDataRecord), as seen earlier. Is this ok or not?
    Last edited by MarkoSan; 7th January 2006 at 11:03.
    Qt 5.3 Opensource & Creator 3.1.2

  8. #8
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Default Re: Record update windowd entered data saving

    No one has idea????
    Qt 5.3 Opensource & Creator 3.1.2

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Record update windowd entered data saving

    Try this(note the "!"):
    Qt Code:
    1. if( ! m_pTableModel->insertRecord( INSERT_RECORD_AT_END, cDataRecord ) )
    2. {
    3. qDebug() << m_pTableModel->lastError().text();
    4. qDebug() << m_pTableModel->query().lastQuery();
    5. }
    To copy to clipboard, switch view to plain text mode 

  10. #10
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Default Re: Record update windowd entered data saving

    Quote Originally Posted by jacek
    Try this(note the "!"):
    Qt Code:
    1. if( ! m_pTableModel->insertRecord( INSERT_RECORD_AT_END, cDataRecord ) )
    2. {
    3. qDebug() << m_pTableModel->lastError().text();
    4. qDebug() << m_pTableModel->query().lastQuery();
    5. }
    To copy to clipboard, switch view to plain text mode 
    I did that, but since operation is sucessfull, qDebug statements are skipped.
    Qt 5.3 Opensource & Creator 3.1.2

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Record update windowd entered data saving

    Quote Originally Posted by MarkoSan
    I did that, but since operation is sucessfull, qDebug statements are skipped.
    How about this?
    Qt Code:
    1. m_pTableModel->insertRecord( INSERT_RECORD_AT_END, cDataRecord );
    2. if( m_pTableModel->submitAll() )
    3. {
    4. qDebug() << "Data submitted successfully";
    5. }
    6. else {
    7. qDebug() << m_pTableModel->lastError().text();
    8. qDebug() << m_pTableModel->query().lastQuery();
    9. }
    To copy to clipboard, switch view to plain text mode 

  12. #12
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Default Re: Record update windowd entered data saving

    So, am I nut or what? This time submitAll failed and first qDebug() we have
    Qt Code:
    1. QSqlQueryModel::lastError returned {...}
    2. QSqlError::text returned {" " size=1}
    To copy to clipboard, switch view to plain text mode 
    and after second qDebug() we have:
    Qt Code:
    1. QSqlQueryModel::query returned {...}
    2. QSqlQuery::lastQuery returned {"SELECT stranka.SIFRA,stranka.DS,stranka.PRIIMEK,stranka.IME,ulica.naziv,stranka.STEVILKA_ULICE,kraj.naziv_kraja FROM stranka,u" size=217}
    To copy to clipboard, switch view to plain text mode 

    What is going on?
    Qt 5.3 Opensource & Creator 3.1.2

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Record update windowd entered data saving

    Quote Originally Posted by MarkoSan
    What is going on?
    Indeed something strange is going on. What does QSqlError::type() return?

  14. #14
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Default Re: Record update windowd entered data saving

    Ok, this is diagnostic code:
    Qt Code:
    1. if(m_pTableModel->submitAll())
    2. {
    3. qDebug() << "Data submitted successfully";
    4. } else
    5. {
    6. qDebug() << m_pTableModel->lastError().text();
    7. qDebug() << m_pTableModel->lastError().type();
    8. qDebug() << m_pTableModel->query().lastQuery();
    9. }
    To copy to clipboard, switch view to plain text mode 

    This is very very strange:
    Qt Code:
    1. QSqlError::type returned NoError
    To copy to clipboard, switch view to plain text mode 

    NoError has been reported!!! How come???
    Qt 5.3 Opensource & Creator 3.1.2

  15. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Record update windowd entered data saving

    SELECT stranka.SIFRA,stranka.DS,stranka.PRIIMEK,stranka.I ME,ulica.naziv,stranka.STEVILKA_ULICE,kraj.naziv_kraja FROM stranka,u
    This stinks... What is the table "kraj" doing here if it's not in the "FROM" part of the query? On the other hand, looks like "u" is not used here, so why is it in the statement? Is that a complete output from lastQuery? Is this a SqlTableModel or QSqlRelationalTableModel? How come SqlTableModel has more than one table in use? Is that last query connected with the model at all?

  16. #16
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Default Re: Record update windowd entered data saving

    Quote Originally Posted by wysota
    This stinks... What is the table "kraj" doing here if it's not in the "FROM" part of the query? On the other hand, looks like "u" is not used here, so why is it in the statement? Is that a complete output from lastQuery? Is this a SqlTableModel or QSqlRelationalTableModel? How come SqlTableModel has more than one table in use? Is that last query connected with the model at all?
    You are right. Does submitAll() generated any SQL statement? The reason I ask is that that statement is responsible for displaying data in QSqlRelationalTableModel and it works fine and lastQuery after sumbitAll still reports that statement, which is obviously not statement for inserting records.

    The statement that I get from debuger is:
    Qt Code:
    1. QSqlQuery::lastQuery returned {"SELECT stranka.SIFRA,stranka.DS,stranka.PRIIMEK,stranka.IME,ulica.naziv,stranka.STEVILKA_ULICE,kraj.naziv_kraja FROM stranka,u" size=217}
    To copy to clipboard, switch view to plain text mode 
    Last edited by MarkoSan; 8th January 2006 at 18:05.
    Qt 5.3 Opensource & Creator 3.1.2

  17. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Record update windowd entered data saving

    Do you have access to that MySQL's query log? Could you check last queries which are executed before getting that wrong behaviour?

  18. #18
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Default Update window problem [DESPERATE - NOT SOLVED]

    Here is log file listing:
    Qt Code:
    1. D:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt, Version: 5.0.16-nt-log. started with:
    2. TCP Port: 3306, Named Pipe: (null)
    3. Time Id Command Argument
    4. 060108 22:42:59 1 Connect root@localhost on possystem
    5. 1 Init DB possystem
    6. 1 Field List stranka
    7. 1 Field List stranka
    8. 1 Field List stranka
    9. 1 Query show index from stranka
    10. 1 Field List stranka
    11. 1 Query SELECT stranka.SIFRA,stranka.DS,stranka.PRIIMEK,stranka.IME,ulica.naziv,stranka.STEVILKA_ULICE,kraj.naziv_kraja FROM stranka,ulica,kraj WHERE (stranka.ULICA=ulica.ulica and stranka.POSTA_STEVILKA=kraj.postna_stevilka)
    12. D:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt, Version: 5.0.16-nt-log. started with:
    13. TCP Port: 3306, Named Pipe: (null)
    14. Time Id Command Argument
    15. 060109 8:53:59 1 Connect root@localhost on
    16. 1 Query SET SESSION interactive_timeout=1000000
    17. 1 Query SELECT @@sql_mode
    18. 1 Query SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
    19. 1 Query SET NAMES utf8
    20. 2 Connect root@localhost on
    21. 2 Query SET SESSION interactive_timeout=1000000
    22. 2 Query SELECT @@sql_mode
    23. 2 Query SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
    24. 2 Query SET NAMES utf8
    25. 2 Quit
    26. 060109 8:59:48 3 Connect root@localhost on possystem
    27. 3 Init DB possystem
    28. 3 Field List stranka
    29. 3 Field List stranka
    30. 3 Field List stranka
    31. 3 Query show index from stranka
    32. 3 Field List stranka
    33. 3 Query SELECT stranka.SIFRA,stranka.DS,stranka.PRIIMEK,stranka.IME,ulica.naziv,stranka.STEVILKA_ULICE,kraj.naziv_kraja FROM stranka,ulica,kraj WHERE (stranka.ULICA=ulica.ulica and stranka.POSTA_STEVILKA=kraj.postna_stevilka)
    34. 060109 8:59:56 3 Quit
    35. 060109 9:00:08 1 Query SHOW VARIABLES LIKE 'datadir'
    36. 1 Query SHOW VARIABLES LIKE 'log_error'
    To copy to clipboard, switch view to plain text mode 
    I do not see INSERT statement anywhere!!
    Last edited by MarkoSan; 9th January 2006 at 19:25.
    Qt 5.3 Opensource & Creator 3.1.2

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.