I am setting up an MS access database table in my asp.net application that will keep prices and have some problems regarding decimal numbers.
To do some testing I have a table with three different field data types:
1) data type Number/Decimal
2) data type Number/Single
3) data type Currency
I try to update and insert data using Gridview and Formview controls. My problem is that only the field defined as Number/Single works as I need.
That is, when I enter 1,23 the value stored in the data base is also 1,23.
The other two fields (defined as Number/Decimal and Currency) works as follows: I enter 1,23 but the value stored in the data base is 123.
I would have thought that the Currency format was the most natural one to use, but now I am confused.
I am developing locally on my laptop using MS Visual Web Developer 2005 Express Edition. I run Windows XP with regional settings defining the comma sign as the decimal separator.
Also the asp.net page is setup as <%@
Page Language="VB"
Culture="da-DK"%>
I would appreciate if someone could help me understand why the "decimals disappear" and also what would be the "best" number data type to use for storing prices (with decimals).
BosseW
Member
54 Points
12 Posts
Choosing data type for prices: I have problem with 1,23 becoming 123
Sep 04, 2007 07:26 PM|LINK
Hi,
I am setting up an MS access database table in my asp.net application that will keep prices and have some problems regarding decimal numbers.
To do some testing I have a table with three different field data types:
1) data type Number/Decimal
2) data type Number/Single
3) data type Currency
I try to update and insert data using Gridview and Formview controls. My problem is that only the field defined as Number/Single works as I need.
That is, when I enter 1,23 the value stored in the data base is also 1,23.
The other two fields (defined as Number/Decimal and Currency) works as follows: I enter 1,23 but the value stored in the data base is 123.
I would have thought that the Currency format was the most natural one to use, but now I am confused.
I am developing locally on my laptop using MS Visual Web Developer 2005 Express Edition. I run Windows XP with regional settings defining the comma sign as the decimal separator.
Also the asp.net page is setup as <%@ Page Language="VB" Culture="da-DK"%>
I would appreciate if someone could help me understand why the "decimals disappear" and also what would be the "best" number data type to use for storing prices (with decimals).