[Qt-interest] SQL (ODBC) retreiving doubles incorrectly

Andre Somers andre at familiesomers.nl
Fri Oct 2 12:22:17 CEST 2009


Andre Somers wrote:
> Hi,
>
> I am running into a very weird issue right now.
> I am using the SQL module to connect to an access database through ODBC. 
> That has served me reasonably well untill now. I am trying to retreive 
> values from a query that returns some floating point values. The data 
> type for the field is correctly identified as as QVariant::double. 
> However, when trying to read values, I get into trouble for values 
> smaller than 0,1. In this case, the QVariant returned seems to contain 
> only the scientific notation part of the value, like E-2 or E-3. Those 
> values alone can obviously not be converted properly into a double, the 
> the .toDouble() call on the QVariant returned from the query returns 0 
> and sets the boolean value passed to check the success to false.
>
> I really need to be able to read any value, even if they are in the 
> range of 1E-10. If I open the query in Access, I can see all the values 
> just fine, and none of them appears in scientic notation.
>
> Any clues how to solve this issue?
>
>
>   
Some additional information:
I am using Qt 4.5.2 on Windows XP 64 (in 32 bit mode). I am using the 
MinGW-32 compiler.

use qDebug() << on the variant value returned from the query, I get 
QVariant(QString, "E-3") as the result. Retreiving the type of the field 
using QSqlRecord::field() and QSqlField::type() returns QVariant::double 
though.

André





More information about the Qt-interest-old mailing list