decimal value in .sdf database
-
I am working on a pocket pc application by using vb.net 2005. I create one table called products and want to store the costprice in decimal in products table. E.g:- if I enter 50.5 for costprice and save it then it automatically changes to 51 which is creating problem for calculation. How I can store decimal value in the table? Anybody knows how I can solve this? Thanks in advance
-
I am working on a pocket pc application by using vb.net 2005. I create one table called products and want to store the costprice in decimal in products table. E.g:- if I enter 50.5 for costprice and save it then it automatically changes to 51 which is creating problem for calculation. How I can store decimal value in the table? Anybody knows how I can solve this? Thanks in advance
ejaz_pk wrote:
How I can store decimal value in the table?
what table? a DataTable? a table in a database, if so which database? Google[^]'s first hit is MSDN[^]. :|
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
-
I am working on a pocket pc application by using vb.net 2005. I create one table called products and want to store the costprice in decimal in products table. E.g:- if I enter 50.5 for costprice and save it then it automatically changes to 51 which is creating problem for calculation. How I can store decimal value in the table? Anybody knows how I can solve this? Thanks in advance
You may also want to post the code that stores the value. There is no automatic rounding or conversion unless the data types are incorrect.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
I am working on a pocket pc application by using vb.net 2005. I create one table called products and want to store the costprice in decimal in products table. E.g:- if I enter 50.5 for costprice and save it then it automatically changes to 51 which is creating problem for calculation. How I can store decimal value in the table? Anybody knows how I can solve this? Thanks in advance
Try setting the field type to be a DECIMAL. (If poss in whatever DB you are using.)
------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
-
I am working on a pocket pc application by using vb.net 2005. I create one table called products and want to store the costprice in decimal in products table. E.g:- if I enter 50.5 for costprice and save it then it automatically changes to 51 which is creating problem for calculation. How I can store decimal value in the table? Anybody knows how I can solve this? Thanks in advance
How are you passing the values to the Db ? if you are storing in some variable/Property then passing to the db then check the Data Type of the Variable/Property. Try to use Quick Watch, if its going ok from Front end then check the Datatype of your Back end(Db). That the field data type is Decimal (18,0), if so then make its Scale to a value greater then 0 i.e; decimal(18, 8)
SOFTDEV If you have knowledge, let others light their candles at it. [ Let's work to help developers, not make them feel stupid ]
-
How are you passing the values to the Db ? if you are storing in some variable/Property then passing to the db then check the Data Type of the Variable/Property. Try to use Quick Watch, if its going ok from Front end then check the Datatype of your Back end(Db). That the field data type is Decimal (18,0), if so then make its Scale to a value greater then 0 i.e; decimal(18, 8)
SOFTDEV If you have knowledge, let others light their candles at it. [ Let's work to help developers, not make them feel stupid ]
:thumbsup: Thanks for the help. As I mentioned that I am using .sdf (sqlserverce) database which used for pocket pc applications. Actually there was problem in the table structure of my database. I was using int type of field in the table. Now I have change that field type to float and its working fine. Thanks every body