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?
    [code]
    strMsg.append(qry.lastError().text());
    [/code]

    Or this:
    [code]
    strMsg.append(db.lastError().text());
    [/code]

    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!



  • @
    if(!qry.exec())
    {
    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.