title: VB.NET - There is no row at position 1 - datatable
body: <p>I am trying to have the contents of a datatable be displayed in a listbox. I cannot, however, figure out what is wrong with my code; I am pretty sure I have tried every way but the right way. I have search through StackOverflow, and the internet in general for an answer, but I cannot find any relevent information. The error I keep getting is:</p>
  
  <p>An unhandled exception of type 'System.IndexOutOfRangeException' occurred in System.Data.dll</p>
  
  <p>Additional information: There is no row at position 1.</p>
  
  <pre><code>    If dt.Rows.Count &gt; 0 Then
          For i As Integer = 0 To dt.Rows.Count()
              lstBoxSaved.Items.Add((dt.Rows(i).Item(0).ToString) &amp; " " &amp;
                         (dt.Rows(i).Item(1).ToString))
          Next i
      Else
          MessageBox.Show("Please clear table", "error: too many entries")
      End If
  </code></pre>
  
  <p>Some while ago I was able to get some variant of this to work for one item, but I need to display all items in the datatable. If there is a more efficient way to display an entire row that would also work.</p>