Company colleagues asked if I have encountered a decimal type of data warehousing, will automatically take the whole problem (such as 12.3 after the value is 12,12.8 storage after the value is 13, after the automatic rounding automatically rounded);
Before the data to go to the decimal type of data, will automatically rounding the problem; I think it should be the same problem, ask colleagues to set the SqlParameter parameter, set scale=2,precision=18; Similar code is as follows:
var New SqlParameter ("@Money", System.Data.SqlDbType.Decimal); - ; 2 ; = Model. Money;
According to the above settings, my colleague said to save to the database or automatic rounding, I was puzzled. There's no way to just go to him. Debug and Trace.
Look at exactly where to take the whole, with a parameter before the storage, the value is not rounded, is the original value, that is, the value of the storage after the automatic rounding. The internet searched the question, did not search the useful answer.
Later look at the structure of the table to know, when the table, the Money field decimal type, did not set the decimal place, every time the storage will be automatically rounded, the field type is changed to decimal (18,2), problem solving.
Add a sentence: true pit ... Write an essay to record the problem of the pit.
About the automatic rounding of. NET when saving decimal type data to a SQLServer2012 database