Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > My decimal is being rounded up by SQL???

Reply
Thread Tools

My decimal is being rounded up by SQL???

 
 
Bruce Duncan
Guest
Posts: n/a
 
      02-17-2004
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
 
Reply With Quote
 
 
 
 
Aaron Bertrand - MVP
Guest
Posts: n/a
 
      02-17-2004
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" <(E-Mail Removed)> wrote in message
news:114a001c3f596$7cb6cc40$(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      02-17-2004
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" <(E-Mail Removed)>

wrote in message
>news:114a001c3f596$7cb6cc40$(E-Mail Removed)...
>> 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

>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to convert from Decimal('1.23456789') to Decimal('1.234') valpa Python 11 03-24-2009 07:11 AM
Error: Cannot convert Decimal("0.0000") to Decimal Vitaliy Python 1 05-29-2008 10:36 AM
TypeError: unsupported operand type(s) for -: 'Decimal' and 'Decimal'. Why? Gilbert Fine Python 8 08-01-2007 01:58 AM
rounded to the nth decimal Gary Wessle C++ 4 03-20-2007 11:11 PM
Decimal to Packed Decimal Conversion in C++ Ven C++ 3 08-01-2006 03:56 PM



Advertisments