title: Getting error Cannot cast DBNull.Value to type 'System.Int32
body: <p>I am grouping data in datatable and summing up one column using linq but while run time i am getting error stating that </p>
  
  <blockquote>
    <p>Cannot cast DBNull.Value to type 'System.Int32. Please use a nullable type" Below is my code</p>
  </blockquote>
  
  <pre><code>Dim resultStyle = invData.Tables(0).AsEnumerable() _
        .GroupBy(Function(v) New With {Key .InvestorStyleID = v.Field(Of Integer)("InstitutionalInvestorStyleID"), Key .StyleName = Not IsNothing(v.Field(Of String)("InstitutionalInvestorStyleName"))}) _
        .Select(Function(v) New With {Key .InvestorStyleID = v.Key.InvestorStyleID, Key .StyleName = v.Key.StyleName, Key .Sum = v.Sum(Function(r) Double.Parse(r.Item("k001ICGeo").ToString()))})
  </code></pre>
  
  <p>Kindly suggest me how to avoid taking null value.I am getting error on second line</p>
  
  <p><code>.GroupBy(Function(v) New With {Key .InvestorStyleID = v.Field(Of Integer)("InstitutionalInvestorStyleID"), Key .StyleName = Not IsNothing(v.Field(Of String)("InstitutionalInvestorStyleName"))}).</code> </p>
  
  <p>I don't want to take the null value.</p>