Read float type field error by QODBC(SQL Server 2017) after upgrade windows patch "November 8, 2022-KB5020686 or KB5020695"
-
After I upgraded window patch (win10 November 8, 2022-KB5020686, win11 KB5020695), if table has float type field, QODBC will raise an error and the column result is QVariant(Invalid).
Below example, query.value(1) will got an QVariant(Invalid) value. But it returned a QVariant(Double) value if I run it on win7(Because win7 does not has such upgrade package).
#include <QCoreApplication> #include <QSqlDatabase> #include <QSqlQuery> #include <QDebug> #include <QSqlError> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QSqlDatabase db = QSqlDatabase::addDatabase("QODBC"); QString dsn = QString("DRIVER=%1;SERVER=%2;PORT=%3;DATABASE=%4;UID=%5;PWD=%6") .arg("{SQL Server}") .arg("127.0.0.1") .arg(1433) .arg("TestDB") .arg("sa") .arg("sa"); db.setHostName("127.0.0.1"); db.setDatabaseName(dsn); db.setUserName("sa"); db.setPassword("sa"); if(!db.open()) { qDebug()<<db.lastError().text(); } else { qDebug()<<"database open success!"; QSqlQuery query(db); query.exec("select id, my_float from my_table"); while(query.next()) { qDebug()<<query.value(0) << query.value(1); } return -1; } } -
See https://bugreports.qt.io/browse/QTBUG-108307 and blame MS :)
Downgrade to an older ODBC driver (or use the recent 17.x one) -
See https://bugreports.qt.io/browse/QTBUG-108307 and blame MS :)
Downgrade to an older ODBC driver (or use the recent 17.x one)Even the topic is old I think the problem was fixed with KB5022282 on January, 10th 2023.