Important: Please read the Qt Code of Conduct -

QSqlDatabase and QSqlQuery

  • I am implementing database connectivity between a C++ application and a script. The script calls a function in the C++ application to connect to the database, this works and the database connection is established.

    The script attempts to perform a query on the database via the C++ application. I'm not sure how to implement error handling correctly at the moment. The query is very simple:

     SELECT * FROM tblTest

    This doesn't appear to return any rows, however if I perform the same query using HeidiSQL on the database, one record is returned.

    How can I tell if there is a problem with the query in the C++ application?

  • Lifetime Qt Champion

    last error is a god starting point
    and output its
    often gives clues if anything it didn't like.

    Also , its important you use next() correctly.

     QSqlQuery query("SELECT * from person ");
        while ( {
        ..use values

Log in to reply