July 5, 2011

EukeSnud EukeSnud
Lab Rat
32 posts

ODBC Driver issue

 

As I published in this thread [developer.qt.nokia.com] I have issues with my ODBC connection, in detail with querying Umlauts from my oracle database.

Here is my code:

  1.  QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
  2.  db.setDatabaseName(dsn);
  3.  QString result;
  4.  QString stmt = "select COL1,COL2 from TABLE_1";
  5.  QSqlQuery query;
  6.  QStringList delist;
  7.  
  8.  if (db.open(user,pwd)) {
  9.   if (query.exec(stmt)) {
  10.    while (query.next()) {
  11.     result = query.value(0).toString() + " - " + query.value(1).toString();
  12.     delist.push_back(result);
  13.    }
  14.   }
  15.   else {
  16.    QMessageBox msgbox;
  17.    msgbox.setText( query.lastError().text() );
  18.    msgbox.exec();
  19.   }
  20.  }
  21.  delist.sort();
  22.  cbDe->addItems(delist); // add to combobox

Umlauts like ä,ö,ü,ß are being displayed as “�” if I choose ODBC driver like in the code above. If I switch from “QODBC” to “QOCI” all Umlauts are transmitted correctly.

This seems do be a driver issue, doesn’t it?

13 replies

July 13, 2011

EukeSnud EukeSnud
Lab Rat
32 posts

bump

July 13, 2011

Theophilus Theophilus
Lab Rat
7 posts

I have a similar if not the same problem. Umlauts like ä,ö,ü,ß are being displayed as “�”.
I’m using Qt 4.7.3, Windows 7, VS2010, and a QODBC3-Driver. I had to build Qt 4.7.3 myself (used this webside: http://www.codeinvain.com/blog/378/installing-qt-4-7-x-for-vs2010), and I had to install the ODBC-plugin for Qt myself (http://doc.qt.nokia.com/4.7-snapshot/sql-driver.html#qodbc). Can anyone help?

 Signature 

Know Yourelf - if you can…

July 14, 2011

Theophilus Theophilus
Lab Rat
7 posts

EukeSnud, I’m just curious: What Qt-Version, DB and OS are you using?

 Signature 

Know Yourelf - if you can…

July 14, 2011

loladiro loladiro
Lab Rat
594 posts

Does the Backend DB you use support Unicode? If so, could you post your DB structure to make sure there’s no error in it.

July 15, 2011

Theophilus Theophilus
Lab Rat
7 posts

I’m using MaxDB (Version 7.6). The Table “DBPARAMETERS” says “_UNICODE” = “NO” and “DEFAULT_CODE” = “ASCII”, which means that the varchar datatype is stored as ascii. However, the same software with an older Qt-Version (4.1) displays the Umlauts correctly.
Here’s some background information: I’ve been trying to integrate an older software into a new environment. The old software was compiled in VS2003 with Qt 4.1. Now I’ve compiled it in VS2010 with Qt 4.7.3. Both versions run properly on Windows 7 with the same ODBC-driver. However, the old one displays the Umlauts correctly, while the new one does not. Therefore, I think it is the newer Qt-Version that is giving me a hard time.

 Signature 

Know Yourelf - if you can…

July 15, 2011

Theophilus Theophilus
Lab Rat
7 posts

This webside says that MaxDB up to and including version 7.6 uses the ASCII-characterset ISO 8859/1.2 (if you chose to use Ascii): http://maxdb.sap.com/doc/7_7/44/bb285be00215b2e10000000a155369/content.htm

 Signature 

Know Yourelf - if you can…

July 15, 2011

loladiro loladiro
Lab Rat
594 posts

Try

  1. QTextCodec::setCodecForLocale(QTextCodec::codecFromName("latin1"));

at the beginning of your application.

July 15, 2011

Theophilus Theophilus
Lab Rat
7 posts

Neither

  1. QTextCodec::setCodecForLocale(QTextCodec::codecForName("Latin1"));

nor
  1. QTextCodec::setCodecForLocale(QTextCodec::codecForName("latin1"));

works.

 Signature 

Know Yourelf - if you can…

July 15, 2011

Theophilus Theophilus
Lab Rat
7 posts

The following code changes the “�” to a “?”. I do not know if that helps at all, to get to the source of the error.

Original code:

  1. QString name =q2.value(1).toString(); //q2 being the QSqlQuery

Changed code (that changes the “�” to a “?”):
  1. QByteArray encodedString = q2.value(1).toByteArray();
  2. QTextCodec *codec = QTextCodec::codecForName("ISO 8859-1");
  3. QString name = codec->toUnicode(encodedString);

 Signature 

Know Yourelf - if you can…

July 19, 2011

EukeSnud EukeSnud
Lab Rat
32 posts

Qt Version is 4.7.3
Db Version is Oracle Enterprise 11.2.0.1.0
Os is Win7 Ultimate x64

July 22, 2011

Theophilus Theophilus
Lab Rat
7 posts

Anyone any idea???

 Signature 

Know Yourelf - if you can…

August 9, 2011

EukeSnud EukeSnud
Lab Rat
32 posts

bump
Still having this issue…

April 13, 2012

Sebtm Sebtm
Lab Rat
1 posts

I have the same problem with a Visual Fox Pro database with the ISO Latin-1 character encoding. I use Qt 4.7.4.

 
  ‹‹ Simulating of QTouchEvent      Stopping QDrag ››

You must log in to post a reply. Not a member yet? Register here!