I'm using a SqlCeDataReader to read results from a query and add them to a list of objects which may return 0 or many rows.
My code:
while (tourReader.Read())
{
Tour newTour = TourDBA.RetrieveTour( (int)reader["Id"] );
if (newTour != null)
creater.Tours.Add(newTour);
}
I would ASSUME that since the Select query should return 0 rows, Read() would return false and thus the loop would never be entered. (I know what's in the table for this test instance, and 0 rows is the expected behavior this test.)
Any idea how to get around this? (Using .HasRows also throws an exception.)
One other thing - the connection I'm using in this query is open, and was used in a different SqCeCommand other than the one being executed here before the method comes to this while loop. If that matters...
Check it:
while (tourReader.Read()) // tourReader here
{
Tour newTour = TourDBA.RetrieveTour( (int)reader["Id"] ); // reader here
if (newTour != null)
creater.Tours.Add(newTour);
}
Are reader
and tourReader
the same?