title: Assigning a DataTable value to a Variable
body: <p>I just wrote a simple method to get some data from an SQL server and store it in a DataTable.</p>
  
  <p>Specifically the value is an integer : 666</p>
  
  <p>It is an int datatype on the database and I made a variable called Credits in C# which is also an integer.</p>
  
  <p>The datatable shows the value 666 in the first row so it got added without any problems.</p>
  
  <p>The problem happens when I try to assign <code>Credits = dt.Rows[0]</code> saying </p>
  
  <blockquote>
    <p>the inputstring was an incorrect format</p>
  </blockquote>
  
  <p>Ive tried parsing it to an int and adding .ToString() but no matter what it gives the same error.</p>
  
  <p>the latest line I tried was </p>
  
  <pre><code>Credits = Convert.ToInt32(dt.Rows[0].ToString());
  </code></pre>
  
  <p>But still no luck. I have looked everywhere online for a solution but I cannot find the problem.
  Any help would be greatly appreciated.</p>