Framework 1.0 and 1.1 differs in conversion of decimals to strings

G

Guest

Lets say i have a decimal value i the database e.g. 20.35. The field in the
database has a scale of 3. When I read this value into a DataSet and the
convert it to a string using ToString() the result is different depending on
if I'm using Framework 1.0 or 1.1. In 1.0 the result is 20.35 which is fine,
but in framework 1.1 the result is 20.350. What I have figured out is that
the behaviour of converting a System.Decimal to a string has changed in
framework 1.1. As we are upgrading a pretty big application from framework
1.0 to 1.1 this is quite a problem for us.

Does anyone know how to get back the old behaviour in framework 1.1, that is
if you have saved a decimal value of 20.35, that will be the value you get
after doing a ToString() without formatting info? We could use other
overridden methods of ToString but the problem is that we are also getting
xml from the dataset and it seems that the default ToString method is used
there as well to convert decimals to xml text, hence the same promblem
occurs.

Johan
 
P

Philip Q [MVP]

I think this is a bug in 1.0 that they fixed in 1.1, as it is now correctly
interpreting the scale property. Try adjusting the scale to 2 - you can do
this either in the database, if you are using output parameters, you might
be able to set this by using setting the SqlParameter.Scale property.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top