Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem connecting to SQL database
Forum Updated to NodeBB v4.3 + New Features

Problem connecting to SQL database

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AlanGifford
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • _ Offline
      _ Offline
      _compiler
      wrote on last edited by
      #2

      @
      if(!qry.exec())
      {
      qDebug() << qry.lastError();
      QString str = qry.lastError().text();
      }
      @

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AlanGifford
        wrote on last edited by
        #3

        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).

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved