title: Arithmetic overflow error converting numeric to data type numeric when datatype is decimal (7,6) in SQL Server
body: <p>I am able to solve the issue when I choose the datatype <code>decimal(5,2)</code>.</p>
  <p>Datatype in all the column is <code>decimal(7,6)</code> in SQL Server.</p>
  <p>Model class</p>
  <pre><code> public double SM1 { get; set; }
   public double SM2 { get; set; }
   public double SM3 { get; set; }
   public double SM4 { get; set; }
  </code></pre>
  <p>Server Side Casting done and tried to convert to decimal is also not working  since I am trying to update a record. And I am getting error as follow :</p>
  <blockquote>
  <p>Arithmetic overflow error converting numeric to data type numeric</p>
  </blockquote>
  <p>Server side code</p>
  <pre><code> int UpdateSaveProductMargin = cls.fncSaveProductMargin(
                               Convert.ToDecimal(viewModel.SM1),
                               Convert.ToDecimal(viewModel.SM2),
                               Convert.ToDecimal(viewModel.SM3),
                               Convert.ToDecimal(viewModel.SM4));
  </code></pre>
  <p>I can't change the database table datatype since multiple application is connected to the same datatype.</p>
  <p>If I change the datatype in server-side code to decimal</p>
  <p>Model class if update</p>
  <pre><code> public decimal SM1 { get; set; }
   public decimal SM2 { get; set; }
   public decimal SM3 { get; set; }
   public decimal SM4 { get; set; } 
  </code></pre>
  <p>Then my <code>ModelState.IsValid</code> returns false and It doesn't go into chunk where update code is written.</p>
  <p>So I need to update the update query for the record which can covert <code>decimal(7,6)</code> to <code>decimal(5,2)</code> or cast the same in C#.</p>