Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Reading numeric from DBRequest
Forum Updated to NodeBB v4.3 + New Features

Reading numeric from DBRequest

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Schubi
    wrote on last edited by
    #1

    Hi everybody

    my problem is to get the right numeric value with 20 digits out of the database.

    I connect to an Microsoft SQL Server over ODBC. I use the SQL Server Native Client 10.0 driver.
    Now comes the problem when i try to select numeric values stored in the database. I have in the Database numeric(20,0) values. In the Result comes a QVariant with the type double.
    When i print the double or transform the double to a string there are problems with the last digits.
    For Example the value in the Database is 10903012224000000001 and in the resultset i got it is 10903012224000000000 (the last 1 changed to 0) or 10903012224000001555 is changed to 10903012224000002048
    Is there any solution to get the right value? I can´t change anythink at the database because the database and the size of the Key as a numeric with 20 digits is given.

    Hope for Help
    Schubi

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Schubi
      wrote on last edited by
      #2

      Hi I found a "bugreport":https://bugreports.qt-project.org/browse/QTBUG-10451

      The solution is to set numericalPrecisionPolicy from LowPrecisionDouble to HighPrecision the following codeline is to add and then the qVariant is qString and everythink works fine

      @
      db.setNumericalPrecisionPolicy(QSql::HighPrecision);
      @

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved