Nominate our 2022 Qt Champions!

Problem connecting to SQL database

  • I have some bigger problems that need to be addressed, but right now I am simply trying to get some error details to help me sort those bigger problems out.

    What is wrong with the following?

    Or this:

    qry is a QSqlQuery object and db is a QSqlDatabase object. My program crashes when it gets to either of these lines (in different parts of the code). I do not have a problem calling other member functions of these objects. Surely I am missing something really simple here...?

    Thanks in advance!

  • @
    qDebug() << qry.lastError();
    QString str = qry.lastError().text();

  • Thanks for the reply! I would really like to know why what I did will not work. I am trying to learn how to avoid having situations like this happen again (with other objects/functions).

Log in to reply