Re: Precision on Output Parameter

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi, Ralph - just butting in!!.

Edward

I think you need to change

Public Function GetTotals(ByVal sStoredProcName As String, sWare As String)
As Long

to

Public Function GetTotals(ByVal sStoredProcName As String, sWare As String)
As single

Argusy


EdwardH wrote:
To give you some background I am calculating space for a particular type of warehouse - @Wareh and getting back @lWspace = 1532.87. Then in VB at the GetTotals line below it shows as 1532. i.e. losing the decimals.

SP:
CREATE PROCEDURE dbo.zSpace
@Wareh nvarchar(3),
@lWspace numeric(8,2) OUTPUT
AS
SET NOCOUNT ON
SELECT @lWspace=SUM(DISTINCT (Height/100)*(Width/100)*(Depth/100))
FROM Partinvent
WHERE (Left(pLocation,3) LIKE @Wareh) and Issued = 0
GO

VB Code:
Public Function GetTotals(ByVal sStoredProcName As String, sWare As String) As Long
Dim oCmd As New ADODB.Command
Dim oParam As ADODB.Parameter
With oCmd
Set .ActiveConnection = invConn
.CommandText = sStoredProcName
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter("Wareh", adChar, adParamInput, 3, sWare)
.Parameters.Append .CreateParameter("lWspace", adNumeric, adParamOutput)
.Parameters(1).Precision = 8
.Parameters(1).NumericScale = 2
.Execute
GetTotals = .Parameters("lWspace")
End With
Set oParam = Nothing
Set oCmd = Nothing
End Function

"Ralph" wrote:


"EdwardH" <EdwardH@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:91AEDEA8-126D-42B6-B928-1B1F06BC6C9F@xxxxxxxxxxxxxxxx

Many thanks I have got it to work however it is bring back the result with

2

dec places. In my Sp I have parameter lWspace numeric (8,2) OUTPUT
which in Query Analyser is resulting in ####.## which is what I want.
But this only comes back into VB as integer ####. In code as you suggested

I

have:
.precision = 8
.numericscale = 2
What am I doing wrong?


How are you retrieving it? Viewing it? That is VB doesn't have a "Numeric"
type.

It would be useful to see some code.

-ralph





.


Quantcast