0

Here is the code:

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();
}

q1 is the correct query. q2 is KNOWINGLY wrong one, cuz there is no table with name "table1".

The deal is: why q1 returns wrong (empty) data with QSqlQuery::record() method, but absolutely right data with QSqlQuery::value() method after q2 is beeing exec()'d?

crew4ok
  • 195
  • 1
  • 3
  • 10
  • I can't reproduce what you describe. This is with PostgreSQL 9.1.3 / Qt 4.8.1. `q1.record()` is not left empty. What RDBMS are you using? – dschulz Apr 25 '12 at 19:45
  • Sorry, now I see the `mysql` tag. So, this may be something mysql-specific. – dschulz Apr 25 '12 at 19:51

0 Answers0