Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Problem saving decimals

Author  Topic 

Pinto
Aged Yak Warrior

590 Posts

Posted - 2005-11-10 : 05:19:42
I want to save a decimal in my sql table. It's an hourly rate. I have my field as smallmoney type. I am updating the table using a sp from my web page. It always rounds my entry up eg 3.75 becomes 4.00. Heres my sp and the line where I am passing the parameter to the sp.

CREATE PROCEDURE spRB_AmendRoomData

@strRoomId int,
@strRoomRef nvarchar (50),
@strFloor nvarchar (50),
@strZone nvarchar(10),
@strLocation nvarchar (100),
@strType nvarchar(50),
@strNo int,
@strDirections nvarchar(2000),
@strPhoneNo nvarchar (50),
@strMaxNo int,
@strEquipmentFac nvarchar(2000),
@strNotes nvarchar(2000),
@strCharge smallmoney,
@strNotInUse bit,
@strIntExt nvarchar(20)


AS
BEGIN
UPDATE tblRB_Rooms SET

RM_RoomRef=@strRoomRef,
RM_Floor=@strFloor,
RM_Zone=@strZone,
RM_Location=@strLocation,
RM_Type=@strType,
RM_No=@strNo,
RM_Directions=@strDirections,
RM_PhoneNo=@strPhoneNo,
RM_MaxNo=@strMaxNo,
RM_Equipment_Facilities=@strEquipmentFac,
RM_Notes=@strNotes,
RM_Charge=@strCharge,
RM_NotInUse=@strNotInUse,
RM_IntExt=@strIntExt


WHERE
RM_RoomId = @strRoomid

END
GO


Cmd.Parameters.Add(New SqlParameter("@strCharge", Me.txtCharge.Text))

Thanks for any help

Pinto
Aged Yak Warrior

590 Posts

Posted - 2005-11-10 : 05:37:55
I've managed to save it, but it is displaying with 4 decimal places in my textbox - which is not a question for this forum.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-11-10 : 05:42:55
if you're using .net you can tell the value in what format do you want it to display.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-10 : 05:49:42
Format will work not only in .net but also in VB/VBA applications

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-11-10 : 05:56:13
true... but i'm working very hard trying to forget those dark times...

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -