I have a code that works well as long as the DB has a result, otherwise C# errors. I use SQL Query extensively to test all SQL scripts and under certain conditions it will return just a header column and NO rows. This is understandable, however I'm not sure how C# understands the DB return. Here's the code that works for a none null data return.
SqlDataReader dr = da1.SelectCommand.ExecuteReader();
strUserName = dr.GetString(0);
else if (!dr.HasRows)
strUserName = "";