Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-89612

CLONE - MacOS ODBC issue

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 4.8.0, 5.2.1, 5.9.6, 5.15.2
    • SQL Support
    • None
    • MacOS 10.6.8, 10.9.2, 10.13, 10.14
    • macOS

    Description

      ODBC is not working correctly in MacOS.

       
      QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
      QString dsn = QString("DRIVER={FileMaker ODBC};SERVER=%1;DATABASE=%2;UID=%3;PWD=%4;").arg(serverName).arg(dbName).arg(user).arg(pass);
      db.setDatabaseName(dsn);
      if(!db.open())
      {
        cout << qPrintable(db.lastError().text()) << endl;
        return -1;
      }
      QSqlQuery q(db);
      if(!q.exec("SELECT * FROM test"))
      {
        cout << qPrintable(q.lastError().text()) << endl;
        return -1;
      }
      while(q.next())
      {
        qDebug() << q.value(0).toString();
      }
      

      Connecting to db and the query don't report any errors, but there are no values printed.
      I have found that, the problem is in qsql_odbc.cpp - QODBCResult::fetchNext() function, line 1043:

       if (d->hasSQLFetchScroll)
              r = SQLFetchScroll(d->hStmt,
                                 SQL_FETCH_NEXT,
                                 0);
          else
              r = SQLFetch(d->hStmt);
      

      d->hasSQLFetchScroll returns true, but SQLFetchScroll returns -1.
      Temporary walkaround for me is using SQLFetch(d->hStmt) instead of SQLFetchScroll.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              liaqi Liang Qi
              dcbenergid Don Bigler
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes