473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Decimal rounds when inserted to SQL2k

Hello

I am calling a stored procedure in a SQL Server 2000 like this:

<code>
SqlCommand cmd = new SqlCommand("Sproc", connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Param", SqlDbType.Decimal).Value = amount;
SqlDataReader reader = cmd.ExecuteReader();
</code>

/amount/ is decimal with the value 0.1, but when I check the
database it contains 0.

Why?

(The field and the sproc both use DECIMAL).
--
Mikael Engdahl

Nov 15 '05 #1
1 1637
Try using the Money type on the SQL Server side.

Regards
Lee

"Mikael Engdahl" <mi******@engdahl.no.spam.com> wrote in message
news:eU**************@TK2MSFTNGP12.phx.gbl...
Hello

I am calling a stored procedure in a SQL Server 2000 like this:

<code>
SqlCommand cmd = new SqlCommand("Sproc", connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Param", SqlDbType.Decimal).Value = amount;
SqlDataReader reader = cmd.ExecuteReader();
</code>

/amount/ is decimal with the value 0.1, but when I check the
database it contains 0.

Why?

(The field and the sproc both use DECIMAL).
--
Mikael Engdahl

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Rob Oldfield | last post by:
From the documentation about Decimal.Round.... "When d is exactly halfway between two rounded values, the result is the rounded value that has an even digit in the far right decimal position. For...
3
by: erikthenomad | last post by:
Hey...I've been cracking head about this one all day, and I'm sure it's an easy answer, but here goes: I have a column entitled Sequ which is defined as a Decimal with Precision 10 and Scale 5. ...
7
by: Alberto | last post by:
Actually I have two quantities (4.61) stored as decimal numbers. Why if I try to sum them the result is 9.23 if the correct value is 9.22? Thank you
4
by: vooose | last post by:
Consider a rounding up function: public static decimal RoundUp(decimal val, decimal round) { return ((decimal)Math.Ceiling((double)(val/round)))*round; } Math.Ceiling (and Math.Floor for...
5
by: Steve Peterson | last post by:
Hello I have a method that returns a decimal. I need to get the lowest integer value from this decimal. For example from "4.9764" I need to get "4", or from "13.134" I need "13". Is there a .Net...
3
by: Matt | last post by:
Anybody noticed that SQL Server rounds up if the value is half way between two rounded values, but C#'s Decimal.Round(Decimal,Int32) rounds to nearest even number? >From MSDN: "When d is exactly...
2
by: Luis P. Mendes | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I've inserted a couple hundred rows in a table in Postgres via psycopg2. The first field of each row is a certain unix time (since epoch)...
14
by: ray | last post by:
Dear all, In my vb.net program, I have to round a decimal number to two decimal place. For example, for the expression "Decimal.Round(31* 1.555, 2)", I should get the result "48.21". However, the...
1
by: methexandude | last post by:
Hi, I'm populating a datagrid with values and adding one of the columns to get a total. It adds up correctly but rounds off the values. For example if the total is 2.56789 it makes it three as a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.