Actually in this line you got this error message
string amp5 = dt6.Tables[0].Rows[0][0].ToString();
In Row[0],there is no data that's way this error showing.
So, before that you check condition and then wrote this lines of code inside the If condition.
if(dt6.Tables[0].Rows.Count>0)
{
string amp5 = dt6.Tables[0].Rows[0][0].ToString();
}