Parameter value is out of range C #

3

Good hope you can help me, I'm doing an insert but at the time of inserting I get the following error. Parameter value 3420590313.72700000 is out of range

my Store procedure that performs the insertion is decimal (19,8) and the column that stores it is the same way decimal (19,8)

This is my SP that saves

ALTER PROCEDURE [dbo].[up_qry_InsertarFlujo_SP]
@OPT                            int ,
@NumeroProceso                  Int,
@Periodo                        Int,
@Soles_VAC_Sobrevivencia        Decimal(19,8),
@Soles_Ajustados_Sobrevivencia  Decimal(19,8),
@Dolares_Sobrevivencia          Decimal(19,8),
@Soles_VAC_Invalidez            Decimal(19,8),
@Soles_Ajustados_Invalidez      Decimal(19,8),
@Dolares_Invalidez              Decimal(19,8),
@gastos_Sepelio_Invalidez_mantenimiento     Decimal(20,8)
as
    IF @opt=1
        BEGIN


            INSERT INTO Flujos_SP(Numero_Proceso,Periodo,Soles_VAC_Sobrevivencia,
                                  Soles_Ajustados_Sobrevivencia,Dolares_Sobrevivencia,
                                  Soles_VAC_Invalidez,Soles_Ajustados_Invalidez,
                                  Dolares_Invalidez,Gastos_Sepelio_Invalidez_mantenimiento)

            VALUES(@NumeroProceso,@Periodo,@Soles_VAC_Sobrevivencia,
                   @Soles_Ajustados_Sobrevivencia,@Dolares_Sobrevivencia,
                   @Soles_VAC_Invalidez,@Soles_Ajustados_Invalidez,
                   @Dolares_Invalidez,@gastos_Sepelio_Invalidez_mantenimiento)

         END

C #:

public bool InsertarFlujos(List<FlujoSP> listaFlujo,int numeroProceso)
{
    bool resultado = false;
    using (var transaccion = base.iniciarTransaccion())
    {
        foreach (var flujo in listaFlujo)
        {
            try
            {
                var parametro = new
                {
                    OPT=1,
                    NumeroProceso = numeroProceso,
                    Periodo = flujo.periodo,
                    Soles_VAC_Sobrevivencia = flujo.soles_VAC_Sobrevivencia,
                    Soles_Ajustados_Sobrevivencia = flujo.soles_Ajustados_Sobrevivencia,
                    Dolares_Sobrevivencia = flujo.dolares_Sobrevivencia,
                    Soles_VAC_Invalidez = flujo.soles_VAC_Invalidez,
                    Soles_Ajustados_Invalidez = flujo.soles_Ajustados_Invalidez,
                    Dolares_Invalidez = flujo.dolares_Invalidez,
                    gastos_Sepelio_Invalidez_mantenimiento = flujo.gastos_Sepelio_Invalidez_mantenimiento,

                };
                resultado = objEjecutar.Ejecutar(transaccion, Sp_InsertarFlujo, parametro, Constante.DuracionTimeOut) > 0 ? true : false;
            }
            catch(Exception ex)
            {
                resultado = false;
                transaccion.Rollback();
                throw new Exception("No se insertar data de flujo del periodo : " + ex);
            }
        }
        transaccion.Commit();
    }
    return resultado;
}



public int32 numero_proceso {get;set;}
public int32 periodo{get;set;}
public decimal soles_vac_sobrevivencia{get;set;}
public decimal soles_ajustados_sobrevivencia{get;set;}
public decimal dolares_sobrevivencia{get;set;}
public decimal soles_vac_invalidez{get;set;}
public decimal soles_ajustados_invalidez{get;set;}
public decimal dolares_invalidez{get;set;}
public decimal gastos_sepelio_invalidez_mantenimiento{get;set;}
    
asked by PieroDev 02.01.2019 в 23:17
source

1 answer

4

Because the data you store is monetary, it is highly recommended to use a data type decimal for the case of C #, since it has a length of 128 bits, that is, you can store up to 28-29 digits. Even if you want to cast a long or double , you will not lose precision.

The equivalent data type in SQL Server is MONEY , and likewise, does not lose precision when doing a cast to another type of data.

If you want to know a little more about type equivalences between C # and SQL Server, you can consult this great answer .

    
answered by 03.01.2019 / 18:33
source