Hi everyone!
I have some problems with using QtSql.
So here's the code first:
QSqlQuery q1
(db_connection
), q2
(db_connection
);
q1.exec("SELECT * from users");
while(q1.next())
{
q2.exec("delete from table1");
if (!q2.isValid())
qDebug() << "q2 is not valid";
if (q1.isActive() && q1.isValid())
qDebug() << q1.record();
}
QSqlQuery q1(db_connection), q2(db_connection);
q1.exec("SELECT * from users");
while(q1.next())
{
q2.exec("delete from table1");
if (!q2.isValid())
qDebug() << "q2 is not valid";
if (q1.isActive() && q1.isValid())
qDebug() << q1.record();
}
To copy to clipboard, switch view to plain text mode
So there are two queries to one database: q1 is absolutely correct and should return several result rows, but q1 is some wrong query.
The question is why QSqlQuery::record() of q1 returns empty data after executing query q2?
I'm using MySQL 5.5.
I repeated this behaviour on qt 4.7.1 and qt 4.8.1 in Windows and Linux.
P.S.: Sorry for my english.
Bookmarks