Re: Precision on Output Parameter
- From: Argusy <argusy@xxxxxxxxxxxxxxx>
- Date: Fri, 06 Apr 2007 23:57:09 +0930
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
.
- Follow-Ups:
- Re: Precision on Output Parameter
- From: Ralph
- Re: Precision on Output Parameter
- From: EdwardH
- Re: Precision on Output Parameter
- References:
- Re: Precision on Output Parameter
- From: Ralph
- Re: Precision on Output Parameter
- From: Ralph
- Re: Precision on Output Parameter
- Prev by Date: Re: strange behavior by deleting tables
- Next by Date: Re: Precision on Output Parameter
- Previous by thread: Re: Precision on Output Parameter
- Next by thread: Re: Precision on Output Parameter
- Index(es):