DataSet Limitation?

Discussion in 'Microsoft ADO .NET' started by Guest, Jan 7, 2004.

  1. Guest

    Guest Guest

    I have a SQL table that has a column defined as Sql Data Type decimal(38,15). In case you are wondering, the precision and scope are that large because it contains 'scientific' numbers which require a range of that size

    Anyway, if I try to fill a DataSet with a DataAdapter, with a simple "select * from table", I get

    System.OverflowException: Conversion overflow

    when it gets to a row that has a column over some value (and I'm sure under some value as well)

    For instance: "1000000000000000.000000000000000" produces the erro

    Does anyone know what this value is? And is there anyway around this, or is it simply the case that .NET DataSet can't handle a Sql Data Type decimal with a precision and/or scope of that size

    TI
     
    Guest, Jan 7, 2004
    #1
    1. Advertisements

  2. Guest

    Guest Guest

    On further review, it looks like the Fill method of the DataAdapter uses int32, which would explain it.

    Is there any way around this, that anyone can think of?

    jdn
     
    Guest, Jan 7, 2004
    #2
    1. Advertisements

  3. Hi,

    This is an know issue, that a "Convertion Overflow" exception will be
    thrown if the precision of the decimal field is greater than 28. This will
    be fixed in the next version of VS.net. The workaround is to use methods
    like SqlDataRead.GetSqlDecimal() to get the decimal values.

    If anything is unclear, please feel free to reply to the post.

    Kevin Yu
    =======
    "This posting is provided "AS IS" with no warranties, and confers no
    rights."
     
    Kevin Yu [MSFT], Jan 8, 2004
    #3
  4. Guest

    Guest Guest

    I am still having problems with it.

    If I try to pull over the value "1000000000000000.000000000000000", I get an overflow. I've tried casting it into decimal and long (I would think long should work), but same "Conversion overflow error." And you can't cast SqlDbDecimal into a double.

    What should I do?

    jdn
     
    Guest, Jan 8, 2004
    #4
  5. Guest

    Guest Guest

    Okay, I got it. You have to do:

    "DataReader.GetSqlDecimal[0].ToDouble()"

    and then you are good to go. I never understand why the syntax of languages are such that "(double)DataReader.GetSqlDecimal[0]" doesn't work, but there is a method to do it.

    I guess there is a method to the madness.

    jdn
     
    Guest, Jan 8, 2004
    #5
  6. Guest

    EBites

    Joined:
    Jun 26, 2011
    Messages:
    1
    Likes Received:
    0
    If you don't mind losing some of the decimal accuracy, casting the value returned by the SQL statement as a float also seems to solve the problem.
     
    EBites, Jun 26, 2011
    #6
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paddy

    GetChanges in a Typed Dataset returns a DataSet??

    Paddy, Jul 3, 2003, in forum: Microsoft ADO .NET
    Replies:
    1
    Views:
    2,768
    Gavin Joyce
    Jul 5, 2003
  2. Lewis Edward Moten III

    Re: Merging untyped dataset into a typed dataset (GUID problems)

    Lewis Edward Moten III, Jul 14, 2003, in forum: Microsoft ADO .NET
    Replies:
    0
    Views:
    5,442
    Lewis Edward Moten III
    Jul 14, 2003
  3. Stephen Muecke

    Re: copy/move rows from a dataset to another dataset?

    Stephen Muecke, Jul 22, 2003, in forum: Microsoft ADO .NET
    Replies:
    1
    Views:
    9,608
    Stefano Meier
    Jul 22, 2003
  4. Richard Roche

    cast dataset to typed dataset

    Richard Roche, Aug 11, 2003, in forum: Microsoft ADO .NET
    Replies:
    3
    Views:
    793
    Richard Roche
    Aug 11, 2003
  5. Guest

    DataSet Limitation? Part 2

    Guest, Jan 8, 2004, in forum: Microsoft ADO .NET
    Replies:
    1
    Views:
    384
    Guest
    Jan 8, 2004
Loading...

Share This Page