Return a decimal value

  • Thread starter Thread starter Guoqi Zheng
  • Start date Start date
G

Guoqi Zheng

Dear Sir,

I am trying to get one decimal value from DB. However, every time, I got an
INT back instead of decimal. For example, if I have 4.75 in DB, I will get a
5 back.

The followings are example of my code. What did I do wrong?


' for output parameters.
Dim objOutputPara As New SqlParameter("@r", SqlDbType.Decimal, 9)
myCommand.Parameters.Add(objOutputPara)
objOutputPara.Direction = ParameterDirection.Output
' Open the connection.
myConnection.Open()
myCommand.ExecuteReader()
ReturnValue = objOutputPara.Value

Below is my stored procedure.

CREATE PROCEDURE MyProc_BookingGetInputHours
@UserId int,
@ActivityId int,
@BookDate smallDatetime,
@r decimal(10,2) = 0 output
AS
Set @r = 0
IF Exists (Select * FROM tblBooking WHERE ActivityId=@ActivityId and
UserId=@UserId and BookDate = @BookDate)
BEGIN
SELECT @r = Hours FROM tblBooking WHERE ActivityId=@ActivityId and
UserId=@UserId and BookDate = @BookDate
END

IF @r = Null
set @r =0
GO



--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com
 
Back
Top