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??
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
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"?
Well, i got the statement:
Qt Code:
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:
QSqlRecord cDataRecord; //cDataRecord.setValue("ULICA", m_pUpdateWindow->GetStreetID()->text()); if(m_pTableModel->insertRecord(INSERT_RECORD_AT_END, cDataRecord)) { { qDebug() << m_pTableModel->query().lastQuery(); } // if } // ifTo 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
Try calling submit() or submitAll() on the model.
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
Maybe the problem is with MySQL 5.0?
Did you try debugging to see if Qt even tries to fill those fields?
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:
The statement in my project is:Qt Code:
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
cDataRecord is declared as:Qt Code:
if(m_pTableModel->insertRecord(INSERT_RECORD_AT_END, 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
No one has idea????
Qt 5.3 Opensource & Creator 3.1.2
Try this(note the "!"):Qt Code:
if( ! m_pTableModel->insertRecord( INSERT_RECORD_AT_END, cDataRecord ) ) { qDebug() << m_pTableModel->lastError().text(); qDebug() << m_pTableModel->query().lastQuery(); }To copy to clipboard, switch view to plain text mode
I did that, but since operation is sucessfull, qDebug statements are skipped.Originally Posted by jacek
Qt 5.3 Opensource & Creator 3.1.2
How about this?Originally Posted by MarkoSan
Qt Code:
m_pTableModel->insertRecord( INSERT_RECORD_AT_END, cDataRecord ); if( m_pTableModel->submitAll() ) { qDebug() << "Data submitted successfully"; } else { qDebug() << m_pTableModel->lastError().text(); qDebug() << m_pTableModel->query().lastQuery(); }To copy to clipboard, switch view to plain text mode
So, am I nut or what? This time submitAll failed and first qDebug() we have
and after second qDebug() we have:Qt Code:
To copy to clipboard, switch view to plain text mode
Qt Code:
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
Indeed something strange is going on. What does QSqlError::type() return?Originally Posted by MarkoSan
Ok, this is diagnostic code:
Qt Code:
if(m_pTableModel->submitAll()) { qDebug() << "Data submitted successfully"; } else { qDebug() << m_pTableModel->lastError().text(); qDebug() << m_pTableModel->lastError().type(); qDebug() << m_pTableModel->query().lastQuery(); }To copy to clipboard, switch view to plain text mode
This is very very strange:
Qt Code:
To copy to clipboard, switch view to plain text mode
NoError has been reported!!! How come???
Qt 5.3 Opensource & Creator 3.1.2
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?SELECT stranka.SIFRA,stranka.DS,stranka.PRIIMEK,stranka.I ME,ulica.naziv,stranka.STEVILKA_ULICE,kraj.naziv_kraja FROM stranka,u
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.Originally Posted by wysota
The statement that I get from debuger is:
Qt Code:
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
Do you have access to that MySQL's query log? Could you check last queries which are executed before getting that wrong behaviour?
Here is log file listing:
I do not see INSERT statement anywhere!!Qt Code:
D:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt, Version: 5.0.16-nt-log. started with: TCP Port: 3306, Named Pipe: (null) Time Id Command Argument 060108 22:42:59 1 Connect root@localhost on possystem 1 Init DB possystem 1 Field List stranka 1 Field List stranka 1 Field List stranka 1 Query show index from stranka 1 Field List stranka 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) D:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt, Version: 5.0.16-nt-log. started with: TCP Port: 3306, Named Pipe: (null) Time Id Command Argument 060109 8:53:59 1 Connect root@localhost on 1 Query SET SESSION interactive_timeout=1000000 1 Query SELECT @@sql_mode 1 Query SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' 1 Query SET NAMES utf8 2 Connect root@localhost on 2 Query SET SESSION interactive_timeout=1000000 2 Query SELECT @@sql_mode 2 Query SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' 2 Query SET NAMES utf8 2 Quit 060109 8:59:48 3 Connect root@localhost on possystem 3 Init DB possystem 3 Field List stranka 3 Field List stranka 3 Field List stranka 3 Query show index from stranka 3 Field List stranka 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) 060109 8:59:56 3 Quit 060109 9:00:08 1 Query SHOW VARIABLES LIKE 'datadir' 1 Query SHOW VARIABLES LIKE 'log_error'To copy to clipboard, switch view to plain text mode
Last edited by MarkoSan; 9th January 2006 at 19:25.
Qt 5.3 Opensource & Creator 3.1.2
Bookmarks