asp.net - Web Service: Decimal Not Being Passed to Database Correctly -


i have web service , can see data member of 0.03 being passed web service database showing 0.000. column in database defined decimal(18,4). data member of business class defined decimal. using visual studio 2010, sql server 2008 , .net 4.0. why isn't 0.03 appearing in database column rather 0.000?

int createapp;  shortsaleinvestorreviewserviceclient _service = new shortsaleinvestorreviewserviceclient();  decimal currentinterestrate = txtcurrentinterestrate.text != string.empty ? decimal.parse(txtcurrentinterestrate.text) : new decimal();  createapp = _service.updateshortsaleapplication(currentinterestrate); 

the web service through linq calls stored procedure update table.


alter procedure [dbo].[updateshortsaleapplication]                  @ishortsaleapplicationid int,    @icurrentinterestrate decimal,        update [shortsaleapplications] set [currentinterestrate] = @icurrentinterestrate     shortsaleapplicationid = @ishortsaleapplicationid    

when stepping through above code, can see "0.03" being passed web-service linq stored procedure. underlying column in database shows "0.0000". column in database defined decimal(18,4). how else can debug or fix?

you have not set precision , scale decimal variable in stored procedure , creating problem.

alter procedure [dbo].[updateshortsaleapplication]
@ishortsaleapplicationid int,
@icurrentinterestrate decimal,

by default sql server takes precision 18 , scale 0.link

p (precision) maximum total number of decimal digits stored, both left , right of decimal point. precision must value 1 through maximum precision of 38. the default precision 18. s (scale) number of decimal digits stored right of decimal point. number substracted p determine maximum number of digits left of decimal point. maximum number of decimal digits can stored right of decimal point. scale must value 0 through p. scale can specified if precision specified. the default scale 0; therefore, 0 <= s <= p. maximum storage sizes vary, based on precision.

change

the column in database defined decimal(18,4)


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -