This question is locked. New answers and comments are not allowed.
I added a stored procedure to my OA data model and generated a domain method for it. The stored procedure returns an Integer result.
Here is the auto generated code:
Public FunctionSpGetCurrentWeight(ByVal fillStation As System.Nullable(Of System.Char)) As Int64 Implements IWWModelUnitOfWork.SpGetCurrentWeight
Dim returnValue As Integer
Return SpGetCurrentWeight(fillStation, returnValue)
End Function
Public Function SpGetCurrentWeight(ByVal fillStation As System.Nullable(Of System.Char), ByRef returnValue As Integer) As Int64 Implements IWWModelUnitOfWork.SpGetCurrentWeight
Dim parameterReturnValue AsNew OAParameter()
parameterReturnValue.Direction= ParameterDirection.ReturnValue
parameterReturnValue.ParameterName= "parameterReturnValue"
Dim parameterFillStation As New Telerik.OpenAccess.Data.Common.OAParameter
parameterFillStation.ParameterName = "FillStation"
If fillStation.HasValue Then
parameterFillStation.Value= fillStation.Value
Else
parameterFillStation.DbType= DbType.String
parameterFillStation.Value= DBNull.Value
End If
Dim queryResult As Int64= Me.ExecuteScalar(Of Int64)("[dbo].[spGetCurrentWeight]", CommandType.StoredProcedure, parameterFillStation,
parameterReturnValue)
If parameterReturnValue.Value Is DBNull.Value Then
returnValue= -1
Else
returnValue= DirectCast(parameterReturnValue.Value, Integer)
End If
Return queryResult
End Function
I created the following function to get the result:
Imports WonderWareDataModel
Module WWDataLookups
Public Function GetWeightFromWonderware(strBay As String) As Int64
Dim lngWeight As Int64 = -999
Try
Using model As New WonderWareDataModel.WWModel
lngWeight = model.SpGetCurrentWeight(strBay)
End Using
Catch
End Try
Return lngWeiight
End Function
End Module
WHenever I call my function GetWeightFromWonderware in my asp page codebehind, an error is thrown in the generated code SpGetCurrentWeight. It is an InvalidCastException at the line Dim queryResult As Int64=Me.ExecuteScalar(Of Int64)("[dbo].[spGetCurrentWeight]",CommandType.StoredProcedure, parameterFillStation, parameterReturnValue).
Can anyone spot what the error is. The sp does return an integer value for the "strBay" parameter that I am testing with.
Any help would be greatly appreciated.
Here is the auto generated code:
Public FunctionSpGetCurrentWeight(ByVal fillStation As System.Nullable(Of System.Char)) As Int64 Implements IWWModelUnitOfWork.SpGetCurrentWeight
Dim returnValue As Integer
Return SpGetCurrentWeight(fillStation, returnValue)
End Function
Public Function SpGetCurrentWeight(ByVal fillStation As System.Nullable(Of System.Char), ByRef returnValue As Integer) As Int64 Implements IWWModelUnitOfWork.SpGetCurrentWeight
Dim parameterReturnValue AsNew OAParameter()
parameterReturnValue.Direction= ParameterDirection.ReturnValue
parameterReturnValue.ParameterName= "parameterReturnValue"
Dim parameterFillStation As New Telerik.OpenAccess.Data.Common.OAParameter
parameterFillStation.ParameterName = "FillStation"
If fillStation.HasValue Then
parameterFillStation.Value= fillStation.Value
Else
parameterFillStation.DbType= DbType.String
parameterFillStation.Value= DBNull.Value
End If
Dim queryResult As Int64= Me.ExecuteScalar(Of Int64)("[dbo].[spGetCurrentWeight]", CommandType.StoredProcedure, parameterFillStation,
parameterReturnValue)
If parameterReturnValue.Value Is DBNull.Value Then
returnValue= -1
Else
returnValue= DirectCast(parameterReturnValue.Value, Integer)
End If
Return queryResult
End Function
I created the following function to get the result:
Imports WonderWareDataModel
Module WWDataLookups
Public Function GetWeightFromWonderware(strBay As String) As Int64
Dim lngWeight As Int64 = -999
Try
Using model As New WonderWareDataModel.WWModel
lngWeight = model.SpGetCurrentWeight(strBay)
End Using
Catch
End Try
Return lngWeiight
End Function
End Module
WHenever I call my function GetWeightFromWonderware in my asp page codebehind, an error is thrown in the generated code SpGetCurrentWeight. It is an InvalidCastException at the line Dim queryResult As Int64=Me.ExecuteScalar(Of Int64)("[dbo].[spGetCurrentWeight]",CommandType.StoredProcedure, parameterFillStation, parameterReturnValue).
Can anyone spot what the error is. The sp does return an integer value for the "strBay" parameter that I am testing with.
Any help would be greatly appreciated.