473,396 Members | 2,011 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,396 software developers and data experts.

My decimal is being rounded up by SQL???

I have a form in an ASP page that the user enters a price
for. When I send the parameter to my SQL stored Proc and
refresh the data, it gets rounded up to the nearest
integer. I can change the data just fine in SQL but not
by using my asp page. Can anyone point me in the correct
direction? Below is my code. TIA
lNewPrice = Request.Form("txtprice")
if isempty(lNewPrice) then
lNewPrice = ""
end if

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open Session("strConn")
Set oCmd = Server.CreateObject("ADODB.Command")
set oCmd.ActiveConnection = oConn
oCmd.CommandText = "spEditSupply"
oCmd.commandtype = AdCmdStoredProc
set RetailParam = oCmd.CreateParameter("@NewRetail",
adDecimal, adParamInput)
RetailParam.Precision = 10
RetailParam.NumericScale = 2
oCmd.Parameters.Append RetailParam
oCmd.Parameters("@NewRetail") = lNewPrice
oCmd.Execute

** The script executes without errors. But when I
refresh the data the entered value of 44.95 is saved as
45.

-Bruce
Jul 19 '05 #1
2 8784
Are you sure the stored procedure is using DECIMAL(10,2) for the parameter?

And that the table data type is defined the same?

And that you aren't applying CLng() or something before passing the data?

And did you try:

set RetailParam = oCmd.CreateParameter("@NewRetail", adDecimal,
adParamInput, 9, lNewPrice)
With RetailParam
.Precision = 10
.Scale = 2
End With
oCmd.Parameters.Append RetailParam

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Bruce Duncan" <an*******@discussions.microsoft.com> wrote in message
news:11*****************************@phx.gbl...
I have a form in an ASP page that the user enters a price
for. When I send the parameter to my SQL stored Proc and
refresh the data, it gets rounded up to the nearest
integer. I can change the data just fine in SQL but not
by using my asp page. Can anyone point me in the correct
direction? Below is my code. TIA
lNewPrice = Request.Form("txtprice")
if isempty(lNewPrice) then
lNewPrice = ""
end if

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open Session("strConn")
Set oCmd = Server.CreateObject("ADODB.Command")
set oCmd.ActiveConnection = oConn
oCmd.CommandText = "spEditSupply"
oCmd.commandtype = AdCmdStoredProc
set RetailParam = oCmd.CreateParameter("@NewRetail",
adDecimal, adParamInput)
RetailParam.Precision = 10
RetailParam.NumericScale = 2
oCmd.Parameters.Append RetailParam
oCmd.Parameters("@NewRetail") = lNewPrice
oCmd.Execute

** The script executes without errors. But when I
refresh the data the entered value of 44.95 is saved as
45.

-Bruce

Jul 19 '05 #2
Ahh...
The parameters of my stored procedure was just using
DECIMAL. I changed to DECIMAL (10,2) and it worked like
a charm.
Thanks for the heads up!

-Bruce
-----Original Message-----
Are you sure the stored procedure is using DECIMAL(10,2) for the parameter?
And that the table data type is defined the same?

And that you aren't applying CLng() or something before passing the data?
And did you try:

set RetailParam = oCmd.CreateParameter("@NewRetail", adDecimal,adParamInput, 9, lNewPrice)
With RetailParam
.Precision = 10
.Scale = 2
End With
oCmd.Parameters.Append RetailParam

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Bruce Duncan" <an*******@discussions.microsoft.com> wrote in messagenews:11*****************************@phx.gbl...
I have a form in an ASP page that the user enters a price for. When I send the parameter to my SQL stored Proc and refresh the data, it gets rounded up to the nearest
integer. I can change the data just fine in SQL but not by using my asp page. Can anyone point me in the correct direction? Below is my code. TIA
lNewPrice = Request.Form("txtprice")
if isempty(lNewPrice) then
lNewPrice = ""
end if

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open Session("strConn")
Set oCmd = Server.CreateObject("ADODB.Command")
set oCmd.ActiveConnection = oConn
oCmd.CommandText = "spEditSupply"
oCmd.commandtype = AdCmdStoredProc
set RetailParam = oCmd.CreateParameter("@NewRetail",
adDecimal, adParamInput)
RetailParam.Precision = 10
RetailParam.NumericScale = 2
oCmd.Parameters.Append RetailParam
oCmd.Parameters("@NewRetail") = lNewPrice
oCmd.Execute

** The script executes without errors. But when I
refresh the data the entered value of 44.95 is saved as
45.

-Bruce

.

Jul 19 '05 #3

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

Similar topics

21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
6
by: John Bentley | last post by:
John Bentley writes at this level: If we think about our savings accounts then division never comes in (as far as I can see). We deposit and withdraw exact amounts most of the time. Occasionaly...
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...
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...
4
by: spebola | last post by:
I am using vb.net 2003 professional and I get the following results when using the round method: dim Amount as decimal = 180.255 Amount = Amount.Round(Amount, 2) Amount now contains 180.25. ...
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...
52
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places?...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.