I'm guessing the error is at
string temp = dr2.GetString(i);
Here you are using i, which is the count of the
rows returned, as an index into the collection of
columns in the data row you are dealing with.
I suspect you want
string temp = dr2.GetString(XXXXX);
where XXXXX is the index to the column you want