G
Guest
I have made this function to create a command object to be used to call a
Stored Procedure:
Public Overrides Function GetStoredProcedureCommandObject(ByVal cn As
ADODB.Connection) As ADODB.Command
'* Create a command objekt to call SP
Dim cmd As New ADODB.Command()
Dim prm As ADODB.Parameter
cmd.ActiveConnection = cn
cmd.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
cmd.CommandTimeout = 15
cmd.CommandText = "LEVE_Lev"
prm = cmd.CreateParameter("nLev", ADODB.DataTypeEnum.adInteger,
ADODB.ParameterDirectionEnum.adParamInput)
MsgBox("Me.Lev=" & Me.Lev)
prm.Value = Me.Lev
cmd.Parameters.Append(prm)
Return cmd
End Function
The parameter is declared as int, and Me.lev contains the value 812
I don't understand why I get the following exception:
************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80020008): Bad variable type.
at ADODB._Parameter.set_Value(Object pvar)
at ADODB.InternalParameter.set_Value(Object value)
at SugroBR.Leverandør.GetStoredProcedureCommandObject(Connection cn)
at SugroData.SugroDataObjekt.GetData(Boolean bClose)
Stored Procedure:
Public Overrides Function GetStoredProcedureCommandObject(ByVal cn As
ADODB.Connection) As ADODB.Command
'* Create a command objekt to call SP
Dim cmd As New ADODB.Command()
Dim prm As ADODB.Parameter
cmd.ActiveConnection = cn
cmd.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
cmd.CommandTimeout = 15
cmd.CommandText = "LEVE_Lev"
prm = cmd.CreateParameter("nLev", ADODB.DataTypeEnum.adInteger,
ADODB.ParameterDirectionEnum.adParamInput)
MsgBox("Me.Lev=" & Me.Lev)
prm.Value = Me.Lev
cmd.Parameters.Append(prm)
Return cmd
End Function
The parameter is declared as int, and Me.lev contains the value 812
I don't understand why I get the following exception:
************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80020008): Bad variable type.
at ADODB._Parameter.set_Value(Object pvar)
at ADODB.InternalParameter.set_Value(Object value)
at SugroBR.Leverandør.GetStoredProcedureCommandObject(Connection cn)
at SugroData.SugroDataObjekt.GetData(Boolean bClose)