tags:

views:

52

answers:

2

Hi, from front end application I am sending the value as 0.15 to database via a stored procedure, but it gets stored as 0 value. Why? please guide. I am using C# + ASP.NET + SQL Server 2008

A: 

I'm pretty sure somewhere in your code your having an int / integer and this is where it get rounded to 0

Fredou
No not at all.I parsed code
Lalit
+2  A: 

What datatype does the column have that you store it into? Also: what datatype does the parameter of the stored procedure have that you use to pass in that value??

My hunch: if you use e.g. DECIMAL then you're using DECIMAL(18,0) --> up to 18 digits, but none after the decimal point. That would truncate 0.15 to 0. Just using DECIMAL as a data type doesn't automatically make it support after-decimal-point digits (a common mistake a lot of SQL programmers make - once - and then they know it).

Make sure both the parameter of the stored proc and the column in the table allow for fractional values, e.g. are something like DECIMAL(18,4) or something like that

marc_s
That would be my guess.
AllenG
offcource Decimal
Lalit
@Lalit: just DECIMAL = DECIMAL(18,0) with **no** digits after the decimal point will **not** work. You need to expcitliy specify DECIMAL(18,2) or something like that - with digits after the decimal point.
marc_s