Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QSqlQuery next()



  • Pls how next() return always true?

    QSqlQuery query;
    query.prepare("SELECT firstName FROM employee WHERE name = ?");
    query.bindValue("MyName");
    query.exec();
    

    query next ist allways true. Table is empty

    if (query.next()) {
        QString firstName = query.value(0).toString(); // this work without fail
        // firstName is NULL;
    }
    

    is there an other way to find out if we got one ore more records?

    [edit: koahnig. Code tags added]



  • @ckvsoft

    Please use code tags in your postings. This makes code sections more readable.

    Checkout size()



  • thx

    I't seem this issue is only when i debug the code, when i put a qDebug in the lines and run my app i can see that next() will return false. confused



  • @ckvsoft which Qt version and compiler do you use?


Log in to reply