Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Value was too large or small for a decimal

Value was too large or small for a decimal

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpcsharpdatabaseoraclequestion
7 Posts 3 Posters 0 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
    salaikumar
    wrote on last edited by
    #1

    Hi... I have a value in oracle DB like "3.50324616E-38".. when I read this value from db in Vc.net using odbcDataReader I get an error like "Value was too large or small for a decimal".. The error is encountered in thi line varname = RdrIns->default::get(row+icnt) ; i tried many methods of Datareader..like .Getint32, GetInt64 GetDecimal etc.. no use any help.???

    Salai

    L D 2 Replies Last reply
    0
    • S salaikumar

      Hi... I have a value in oracle DB like "3.50324616E-38".. when I read this value from db in Vc.net using odbcDataReader I get an error like "Value was too large or small for a decimal".. The error is encountered in thi line varname = RdrIns->default::get(row+icnt) ; i tried many methods of Datareader..like .Getint32, GetInt64 GetDecimal etc.. no use any help.???

      Salai

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Did you try a double?

      led mike

      S 1 Reply Last reply
      0
      • L led mike

        Did you try a double?

        led mike

        S Offline
        S Offline
        salaikumar
        wrote on last edited by
        #3

        Yaa I tried.... tried all the methods supported by the OdbcDataReader...

        Salai

        1 Reply Last reply
        0
        • S salaikumar

          Hi... I have a value in oracle DB like "3.50324616E-38".. when I read this value from db in Vc.net using odbcDataReader I get an error like "Value was too large or small for a decimal".. The error is encountered in thi line varname = RdrIns->default::get(row+icnt) ; i tried many methods of Datareader..like .Getint32, GetInt64 GetDecimal etc.. no use any help.???

          Salai

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          It doesn't work because of exactly what the error message says. The smallest value a Decimal type can have is (+/-)1E-28. You're trying the move the decimal point 10 places more to the left than the Decimal type can handle.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008

          S 1 Reply Last reply
          0
          • D Dave Kreskowiak

            It doesn't work because of exactly what the error message says. The smallest value a Decimal type can have is (+/-)1E-28. You're trying the move the decimal point 10 places more to the left than the Decimal type can handle.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007, 2008

            S Offline
            S Offline
            salaikumar
            wrote on last edited by
            #5

            Thanks Dave... I understud... Is there any other method to handle this data.. The datatype of that column in Oracle is Binary_FLoat. While oracle can store that data why cant .Net access that data??.. I tried with Rdr->GetData Rdr->GetDecimal Rdr->Getint16,32 Rdr->GetDouble Rdr->GetFloat etc.... Nothing works...

            Salai

            D 1 Reply Last reply
            0
            • S salaikumar

              Thanks Dave... I understud... Is there any other method to handle this data.. The datatype of that column in Oracle is Binary_FLoat. While oracle can store that data why cant .Net access that data??.. I tried with Rdr->GetData Rdr->GetDecimal Rdr->Getint16,32 Rdr->GetDouble Rdr->GetFloat etc.... Nothing works...

              Salai

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              salaikumar wrote:

              While oracle can store that data why cant .Net access that data??

              Was .NET written by Oracle?? No. There's nothing that says Microsoft has to support every feature of every database or anything else that might come .NETs way. You have to use the Double data type to store the value. It's range is (copied from MSDN documentation): -1.79769313486231570E+308 through -4.94065645841246544E-324 † for negative values; 4.94065645841246544E-324 through 1.79769313486231570E+308 † for positive values

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007, 2008

              S 1 Reply Last reply
              0
              • D Dave Kreskowiak

                salaikumar wrote:

                While oracle can store that data why cant .Net access that data??

                Was .NET written by Oracle?? No. There's nothing that says Microsoft has to support every feature of every database or anything else that might come .NETs way. You have to use the Double data type to store the value. It's range is (copied from MSDN documentation): -1.79769313486231570E+308 through -4.94065645841246544E-324 † for negative values; 4.94065645841246544E-324 through 1.79769313486231570E+308 † for positive values

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                     2006, 2007, 2008

                S Offline
                S Offline
                salaikumar
                wrote on last edited by
                #7

                Thanks Dave.. When I tried with double, it returns error for other columns..(Since it is a generic function). Atlast I handled this problem by having a try catch with over flow exception and replaced this value with zero to display in reports since this value is very small.. Thanks for your concern to reply.

                Salai

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups