Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 57

Thread: Record update windowd entered data saving

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

    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

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

    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?

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

    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

  4. #24
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    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?

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

    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 19:05.
    Qt 5.3 Opensource & Creator 3.1.2

  6. #26
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    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?

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

    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 20:25.
    Qt 5.3 Opensource & Creator 3.1.2

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

    Default Re: Record update windowd entered data saving

    Please help!!!
    Qt 5.3 Opensource & Creator 3.1.2

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

    Default Re: Record update windowd entered data saving

    Does insertRecord() return true?
    Last edited by wysota; 10th January 2006 at 11:24.

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

    Default Re: Record update windowd entered data saving

    Yes, I've tried it several times. submitAll also returns true, there is no visible error (in debugger), just empy field is added to QSqlRelationDataModel (not to databse, becasue if I reopen window, the empty field dissapears). I thought it was something wrong with relations, so I commented relation setup, still same result. Do you need whole code listing?
    Qt 5.3 Opensource & Creator 3.1.2

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

    Default Re: Record update windowd entered data saving

    Try this:

    Qt Code:
    1. rec.append(QSqlField("id", QVariant::Int));
    2. rec.append(QSqlField("name", QVariant::String));
    3. rec.append(QSqlField("address", QVariant::String));
    4. rec.setValue("id", lineedit1->text());
    5. rec.setValue("name", lineedit2->text());
    6. rec.setValue("address", lineedit3->text());
    7. //...
    8. model->insertRecord(-1, rec);
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Record update windowd entered data saving

    God damn, it works, but still there is no data in the table after reopening the window! Is this problem maybe connected with my databse schematic, because I have an ID field in customer table autonumbered, but I cannot get its value from SQL to Qt?
    Qt 5.3 Opensource & Creator 3.1.2

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

    Default Re: Record update windowd entered data saving

    Quote Originally Posted by wysota
    Try this:

    Qt Code:
    1. rec.append(QSqlField("id", QVariant::Int));
    2. rec.append(QSqlField("name", QVariant::String));
    3. rec.append(QSqlField("address", QVariant::String));
    To copy to clipboard, switch view to plain text mode 
    I just wonder why didn't we thought about this earlier

    A shorter version:
    Qt Code:
    1. QSqlRecord rec( m_pTableModel->record() );
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Record update windowd entered data saving

    Quote Originally Posted by jacek
    I just wonder why didn't we thought about this earlier

    A shorter version:
    Qt Code:
    1. QSqlRecord rec( m_pTableModel->record() );
    To copy to clipboard, switch view to plain text mode 
    But isn't there a QSqlDatabase connection or some other mechanism, which fetches fields names automaticly?
    Qt 5.3 Opensource & Creator 3.1.2

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

    Default Re: Record update windowd entered data saving

    Quote Originally Posted by MarkoSan
    But isn't there a QSqlDatabase connection or some other mechanism, which fetches fields names automaticly?
    Now it works, thank you very very much! But can you please tell me how to fetch ID of CUSTOMER, which is set to AUTONUMBER in SQL Administrator, but it does not work, since If I add record manualy, the ID does not grow!!
    Qt 5.3 Opensource & Creator 3.1.2

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

    Default Re: Record update windowd entered data saving

    Quote Originally Posted by MarkoSan
    But isn't there a QSqlDatabase connection or some other mechanism, which fetches fields names automaticly?
    That's what QSqlTableModel::record() does.

    Quote Originally Posted by MarkoSan
    can you please tell me how to fetch ID of CUSTOMER, which is set to AUTONUMBER in SQL Administrator, but it does not work, since If I add record manualy, the ID does not grow!!
    Try:
    Qt Code:
    1. rec.setGenerated( "id", false );
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Record update windowd entered data saving

    Ok, I have another question: Why do I get now table filled with new data correctly, but If i reopen windows, the data dissapears, that means, record is still not being written to database?
    Qt 5.3 Opensource & Creator 3.1.2

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

    Default Re: Record update windowd entered data saving

    Did you try QSqlTableModel::submit() or QSqlTableModel::submitAll()?

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

    Default Re: Record update windowd entered data saving

    I checked it out, just wait, now returns false, I'll post the error soon.
    Qt 5.3 Opensource & Creator 3.1.2

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

    Default Re: Record update windowd entered data saving

    Quote Originally Posted by MarkoSan
    I checked it out, just wait, now returns false, I'll post the error soon.
    submitAll returns false, further diagnostic:
    Qt Code:
    1. QSqlError::type returned StatementError
    2. QSqlQueryModel::query returned {...}
    3. 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 
    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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.