i use SqlDataReader
to read data from query result,i run the debugger and the query is working. hasrows is true, but it shows Enumeration yielded no results.
this is my code :
SqlCommand selectLastData = new SqlCommand("SELECT TOP 1 * FROM tbl_transaksi ORDER BY id DESC", conn);
using (SqlDataReader rdr = selectLastData.ExecuteReader())
{
if (rdr.HasRows)
{
while (rdr.Read())
{
string id = rdr["id"].ToString();
}
rdr.Close();
}
}