Noam M Noam M - 1 year ago 103
Linux Question

QSqlQuery returns "???" for none English string

When running the code below the result is 'אבגדה' in Windows and '?????' on Linux, seems that

(a QVarient type) using a defult coding. In Linux I'm using free.dts and odbc.ini in the driver level

How to set QSqlQuery so that the return format will be UTF16?

What is the returned format?

QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("..."); //Some valid connection string

QByteArray ba;
char* _buffer11;

QSqlQuery qry(db);
qry.prepare("Select UTF16 From DataTypes WHERE ID=9");

//* Parse query results to DT format and write it to temp buffer.
QVariantList resultList;

resultList << qry.value(0);

// ...

Answer Source

I found the solution, the line client charset = UTF-8 should be added to the freetds.conf file

host     =
instance = SQLEXPRESS   
tds version = 8.0
client charset = UTF-8
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download