none
Database Field Value Being "Auto" Rounded Up?? RRS feed

  • Question

  • Hi there,

    I'm sorry if this is in the wrong thread but I am not sure exactly where this query should be....I am trying to use ODBC to query a Progress (4gl) database and populate a list with the values that get returned.

    I have created a new ODBCConnection, ODBCCommand and an ODBCDataReader class to do the job; I've setup the connection string and am using a SQL query to pull the data from the table since the Progress table is "SQL Enabled" so it understands how to interpret SQL.

    What I am finding is that the values getting returned from the DataReader are being rounded up to 2 decimal places. IE: if the value in the database is "0.065", my list receives "0.07".

    The Progress table field type I am receiving is a System.Decimal.

    I tried to eliminate the casting of the data into the list by coding the following:

    var theResult = DataReader.GetDecimal(12); But this still rounded the value implying that it was the DataReader itself doing the rounding?

    I tried to use a different list type EG: List<String> Test = DataReader.GetString(12); But this just threw an exception complaining about it being an invalid cast....

    After failing to understand why the DataReader was rounding the value, I assumed it was inherent to the class itself so I then tried to use an ODBCDataAdapter to fill a dataset and then populate the list<decimal> from the dataset. I still received "0.07" instead of "0.065"??

    I am running Progress OpenEdge 10.1C ODBC Drivers inside Windows Server 2008 R2 Datacenter. I am using Visual Studio C# Express 2010, and the project is being built into a .NET 3.5 framework build.

    Has anyone experienced this before who could offer some advice please?

    Thanks in advance!

    Wednesday, November 7, 2012 12:58 PM

Answers

  • Hi guys,

    Thanks for all the feedback!! I'm happy to say that I am NOT going crazy....I just needed to strangle the Progress developer who told me that the value was categorically "0.065" in the database table, and it was my problem.

    I spoke to a Progress DBA when I couldn't get any proof that it was my code doing the rounding and he came back saying No...the value was indeed "0.07" and that's what I was being handed from the database.

    It had nothing to do with my classes I was using!!!

    Sorry to mess you around!

    • Marked as answer by Funbean Friday, November 9, 2012 12:58 PM
    Friday, November 9, 2012 12:58 PM

All replies

  • When you looked at 'theResult' were you viewing it in your list or the debugger?

    Try using DataReader.GetDouble() or .GetFloat() to see if it makes a difference.


    This signature unintentionally left blank.

    Thursday, November 8, 2012 12:23 AM
  • Thanks for the reply....

    I have tried using GetDouble and GetFloat, but it always throws an exception saying "Specified cast is not valid."

    I always view it in my debugger....

    Thursday, November 8, 2012 5:29 AM
  • I'm not clear, Is the casting error in your code, or comming from inside the reader?

    You can also try modifying the SQL to convert the value.  Not sure what it would look like for your Progress DB, but something like

    SELECT CAST(COLNAME1, VARCHAR(10)) AS COLNAME1TEXT FROM ...


    This signature unintentionally left blank.

    Thursday, November 8, 2012 12:07 PM
  • Hi guys,

    Thanks for all the feedback!! I'm happy to say that I am NOT going crazy....I just needed to strangle the Progress developer who told me that the value was categorically "0.065" in the database table, and it was my problem.

    I spoke to a Progress DBA when I couldn't get any proof that it was my code doing the rounding and he came back saying No...the value was indeed "0.07" and that's what I was being handed from the database.

    It had nothing to do with my classes I was using!!!

    Sorry to mess you around!

    • Marked as answer by Funbean Friday, November 9, 2012 12:58 PM
    Friday, November 9, 2012 12:58 PM