title: sum column in datatable vb.net 2010
body: <p>I am trying to get the sum of the column <code>TotalAmount</code> in my <code>DataTable</code> <code>dt</code> but I always get this error:</p>
  
  <blockquote>
    <p>Object reference not set to an instance of an object.</p>
  </blockquote>
  
  <p>I am using VB in Visual Studio 2012.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>Dim table As DataTable = CartDataSet.Tables("dt")
  Dim result As Integer
  result = table.Compute("SUM(TotalAmount)", "")
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/6KnHl.jpg" alt="Screenshot"></p>