Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
rama108
Posting Yak Master
115 Posts |
Posted - 2014-04-07 : 18:06:47
|
Hello, I have a float datatype and it does not add a decimal point if a number is whole. For example, 500 should be 500.00. I cannot use decimal instead of float, otherwise C# complains about it. How can I keep the float datatype and display the number as 500.00?Thank you for your time,Ram. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-04-07 : 18:37:20
|
You need to figure out why "C#" is complaining about the decimal data type as float is not the proper data type in most cases. It should be used for scientific data ONLY. It's not C# that is the problem. It's your code. We use decimal data type without any issues in C#, Java, etc.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
rama108
Posting Yak Master
115 Posts |
Posted - 2014-04-07 : 19:45:39
|
Hello Tara, I change the datatype from float to Decimal(18,2) in SQL, then I update the edmx. When I look at the generated code, the column is showing double instead of decimal in C#. I cannot change this to decimal manully since this is generated data. Then when I run it, it shows the error as "the property could not be set to a 'System.Decimal' value. You must set this property to a non-null value of type 'System.Double'. Also, note that there are no null values in the data for this column. This column is defined as not null. |
|
|
rama108
Posting Yak Master
115 Posts |
Posted - 2014-04-07 : 20:11:04
|
The issue was that i had float as datatype in Sql and then added the edmx. After I changed the datatype to Decimal, the edmx update would not update the datatype in the C# project. So had to remove the class from edmx. Added it back again and error is gone. Thanks for your time. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2014-04-08 : 07:25:21
|
Also note that you can easily apply the number formation in C# using a String.Format methodMadhivananFailing to plan is Planning to fail |
|
|
|
|
|
|
|