Error inserting monetary value into bank

0

I'm trying to save the value 137421.20 in a SqlServer table with a field of type Numeric (8.2). But I get an error with the description:

"Parameter value 137421.20 is out of range."

I'm trying to enter the value in the FileTracker_TotalValue field

I'm using the Entity Framework and my model is with the following code:

 public partial class ARQUIVO_GERADO_TRAILLER
    {
        public int ID_Arquivo { get; set; }
        public string ArquivoTrailler_Conteudo { get; set; }
        public int ArquivoTrailler_TotalLinhas { get; set; }
        public decimal ArquivoTrailler_TotalValor { get; set; }
    }

The call in the class that is entering the values is with the code below:

objArquivoGeradoTrailler.ID_Arquivo = 90;
objArquivoGeradoTrailler.ArquivoTrailler_Conteudo = "texto";
objArquivoGeradoTrailler.ArquivoTrailler_TotalLinhas = 477;
objArquivoGeradoTrailler.ArquivoTrailler_TotalValor = 137421,20;

db.ARQUIVO_GERADO_TRAILLER.Add(objArquivoGeradoTrailler);
db.SaveChanges();

I can insert this value directly into the database table, through an insert script. But by feeding the FileTracker_TotalValue attribute that is of decimal type I get the error described above.

    
asked by anonymous 21.02.2017 / 21:43

1 answer

0

Good evening,

Try using the "." instead of "," in decimal value.

objArquivoGeradoTrailler.ArquivoTrailler_TotalValor = 137421.20;

or you can use the

objArquivoGeradoTrailler.ArquivoTrailler_TotalValor = decimal.Parse(137421,20);
    
22.02.2017 / 00:45