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

Qt SQL: German umlauts in table names with ODBC for MS-Access

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.15.0 Beta2
    • 5.14.1
    • SQL Support
    • None
    • Windows
    • 114394702b2975b5d890833a5f14510b5e1a2e2b (qt/qtbase/5.15)

    Description

      We are currently working with Qt SQL to read from a MS-Access database by an ODBC driver. In that regard we want to get metadata like the table names in the database. These table names don't contain the German umlauts used in MS-Access and you can't convert the string either in order to get the umlauts.

      Here ist an example with the German word "Ortsschlüssel".

      The following code snippet shows the general concept.

       

      QSqlDatabase QtDb = QSqlDatabase::addDatabase("QODBC", "AccessDB");
      QString databaseName("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DSN='';DBQ=db.mdb");
      QtDb.setDatabaseName(databaseName);
      bool result= QtDb.open();
      ...
      for (short i = 0; i < QtDb.tables().size(); i++)
      {
          qDebug() << "table name: " << QtDb.tables().value(i);
      }
      

       

      Therefore we stepped into the Qt Code, especially the method tables(QSql::TableType type) in qsql_odbc.cpp. In line 2388 the table name is determined:

      QString fieldVal = qGetStringData(hStmt, 2, -1, false);

      In our opinion the hard-wired false is wrong because of line 507

       

      fieldVal += QString::fromUtf8(reinterpret_cast<const char *>(buf.constData()), realsize);
      

      The buffer buf simply doesn't contain the correct value for the German umlauts to be converted from Utf-8. If you call qGetStringData with unicode = true, the umlauts are treated right.

      We hope you could understand our problem and look forward to hear from you soon.

       

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-82401
          # Subject Branch Project Status CR V

          Activity

            People

              mabrand Mark Brand
              pmime Peter Steibert
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes