I have been trying to get it working for almost an hour now and cannot make any sense why it is not working. Please help!! This is my code
SqlDataReader rs = cmdGet.ExecuteReader();
rs.Read();
var id = Convert.ToInt32(rs["id"]);
var mt = rs["mt"].ToString();
The SQL statement is this:
SELECT TOP 1
id = 0,
mt = MT
FROM
MyTable
ORDER BY
2
I id = 0 and the code breaks at mt line. Throws:
System.IndexOutOfRangeException
What's wrong? I looked at a lot of posts but could not resolve it.
