It doesn’t matter what the first document is called, it is always excluded from the list with this code. I can run the same select statement against the DB and the correct results show. I think I have just looked at the code too much to see the issue.
SqlConnection objConn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBName"].ToString());
objConn.Open();
string sTSQL =
"SELECT [filename] " +
"FROM [DB].[dbo].[secure_files] ";
SqlCommand objCmd = new SqlCommand(sTSQL, objConn);
objCmd.CommandType = CommandType.Text;
SqlDataReader dr = objCmd.ExecuteReader();
dr.Read();
html += "<ul>";
while (dr.Read())
{
html += "<li><a href=\"/secure/secureDownload.aspx?query=" + dr[0].ToString() + "\">" + dr[0].ToString() + "</a></li>";
}
html += "</ul>";
objConn.Close();
I think this is because you call
dr.Read();twice. Just remove the first one.