G
Guest
Hi,
when I attempt to call a SQLServer UDF from VBA/ADODB I get an errormessage:
Runtime error: -2147467259
Invalid scaling
UDF is as follows
CREATE FUNCTION [dbo].[fZeiteinheitUmrechnen] (
@Wert as decimal(10,2) ,
@QuellZeiteinheit as int,
@ZielZeiteinheit as int
)
RETURNS decimal(10,2) AS
BEGIN
Declare @ZeitZiel as decimal(10,2)
Select @ZeitZiel = Round (@Wert * UMRECHNUNGSFAKTOR , 2)
From TB_ZEITEINHEIT_UMRECHNUNG
Where ZEITEINHEITNUMMER = @QuellZeiteinheit and
ZIELZEITEINHEITNUMMER = @ZielZeiteinheit
Return (@ZeitZiel)
END
VBA Function:
Public Function ZeiteinheitUmrechnen( ZeitWert As Double,
Quellzeiteinheit As
Integer,
Zielzeiteinheit As
Integer) As Double
Dim cmd As New ADODB.Command, par As ADODB.Parameter
With cmd
.CommandText = "dbo.fZeiteinheitUmrechnen"
.CommandType = adCmdText
Set par = .CreateParameter("pReturn", adDecimal,
adParamReturnValue)
par.NumericScale = 10
par.Precision = 2
.Parameters.Append par
Set par = .CreateParameter("pWert", adDecimal, adParamInput, ,
ZeitWert)
par.NumericScale = 10
par.Precision = 2
.Parameters.Append par
Set par = .CreateParameter("pQZeiteinheit", adInteger,
adParamInput, , Quellzeiteinheit)
.Parameters.Append par
Set par = .CreateParameter("pZZeiteinheit", adInteger,
adParamInput, , Zielzeiteinheit)
.Parameters.Append par
.ActiveConnection = CurrentProject.Connection
.Execute
ZeiteinheitUmrechnen = .Parameters("pReturn").Value
End With
Set cmd = Nothing
Set par = Nothing
End Function
Can anyone help how to troubleshoot?
when I attempt to call a SQLServer UDF from VBA/ADODB I get an errormessage:
Runtime error: -2147467259
Invalid scaling
UDF is as follows
CREATE FUNCTION [dbo].[fZeiteinheitUmrechnen] (
@Wert as decimal(10,2) ,
@QuellZeiteinheit as int,
@ZielZeiteinheit as int
)
RETURNS decimal(10,2) AS
BEGIN
Declare @ZeitZiel as decimal(10,2)
Select @ZeitZiel = Round (@Wert * UMRECHNUNGSFAKTOR , 2)
From TB_ZEITEINHEIT_UMRECHNUNG
Where ZEITEINHEITNUMMER = @QuellZeiteinheit and
ZIELZEITEINHEITNUMMER = @ZielZeiteinheit
Return (@ZeitZiel)
END
VBA Function:
Public Function ZeiteinheitUmrechnen( ZeitWert As Double,
Quellzeiteinheit As
Integer,
Zielzeiteinheit As
Integer) As Double
Dim cmd As New ADODB.Command, par As ADODB.Parameter
With cmd
.CommandText = "dbo.fZeiteinheitUmrechnen"
.CommandType = adCmdText
Set par = .CreateParameter("pReturn", adDecimal,
adParamReturnValue)
par.NumericScale = 10
par.Precision = 2
.Parameters.Append par
Set par = .CreateParameter("pWert", adDecimal, adParamInput, ,
ZeitWert)
par.NumericScale = 10
par.Precision = 2
.Parameters.Append par
Set par = .CreateParameter("pQZeiteinheit", adInteger,
adParamInput, , Quellzeiteinheit)
.Parameters.Append par
Set par = .CreateParameter("pZZeiteinheit", adInteger,
adParamInput, , Zielzeiteinheit)
.Parameters.Append par
.ActiveConnection = CurrentProject.Connection
.Execute
ZeiteinheitUmrechnen = .Parameters("pReturn").Value
End With
Set cmd = Nothing
Set par = Nothing
End Function
Can anyone help how to troubleshoot?