First,
Math.Round
always works, especially if you spell it correctly :-). Why would you tell us something which is not true?
More importantly, if you really work with floating-point numbers, rounding them before putting them in a database
is a crime in nearly all situations. You don't need it. Database-stored floating-point values are never any "final" figures, then can later be used in some calculations as the intermediate or input values; and
rounding errors in intermediate values tends to accumulate.
Even though you might need rounded values to be presented on screen, this is a very bad excuse for storing rounded values in the database. You never need it. If you need rounded presentation, this is not actually rounded, but formatting using, say,
string.Format
. Please see:
http://msdn.microsoft.com/en-us/library/system.string.format.aspx[
^],
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx[
^],
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx[
^].
Format specifiers shown in the last two links will help you to provide required presentation of data.
Don't put it the string form in your database!
—SA