It's as simple as the error message states: There is no row at row-index 0 of that table. The table is empty. At the line above you seem to check for the row count but it's apparently a different table you're checking there. Maybe it should look like this instead?:
If dt.Tables(0).Rows.Count > 0 Then