← Tutti gli articoli
Error converting data type decimal to decimal
29 April 2011 ·
Troubleshooting · Article ·
992 visite
Migration from MS SQL Server 2008 to 2008 R2 - Language Integrated Query - LINQ
I have the following store procedure:
- procedure [dbo].[sp_SpidBustaGet_RBM] ( @ID_SpidBustaPaga int , @NumeroMesi int , @Euro money out , @Valuta money out , @rfr decimal (18,3) out , @val_cod_valuta char (3) out )
- //The Linq mapping is:
- [Function(Name="dbo.sp_SpidBustaGet_RBM")]
- public int sp_SpidBustaGet_RBM([Parameter(Name="ID_SpidBustaPaga", DbType="Int")] System.Nullable<int> iD_SpidBustaPaga, [Parameter(Name="NumeroMesi", DbType="Int")] System.Nullable<int> numeroMesi, [Parameter(Name="Euro", DbType="Money")] ref System.Nullable<decimal> euro, [Parameter(Name="Valuta", DbType="Money")] ref System.Nullable<decimal> valuta, [Parameter(DbType="Decimal")] ref System.Nullable<decimal> rfr, [Parameter(DbType="Char(3)")] ref string val_cod_valuta)
- {
- IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), iD_SpidBustaPaga, numeroMesi, euro, valuta, rfr, val_cod_valuta);
- euro = ((System.Nullable<decimal>)(result.GetParameterValue(2)));
- valuta = ((System.Nullable<decimal>)(result.GetParameterValue(3)));
- rfr = ((System.Nullable<decimal>)(result.GetParameterValue(4)));
- val_cod_valuta = ((string)(result.GetParameterValue(5)));
- return ((int)(result.ReturnValue));
- }
I have the 3 nullable output parameter: euro , valuta and _rfr
The previous Sql Server 2008 worked fine with the following initialization:
decimal? euro = 0, valuta = 0, decimal? _rfr = 0;
n = linqContra.sp_SpidBustaGet_RBM(ID_SpidBustaPaga, 12, ref euro, ref valuta, ref _rfr, ref val_cod_valuta);
in the R2 I have a decimal to decimal convert data type error.
Solution:
Set the output parameters to null:
decimal? euro = null, valuta = null, decimal? _rfr = null;