Search code examples
c#idatareader

Does IDataReader.GetName(i) work with empty data readers?


I want in the case of an empty data reader to output the field names with empty values.. ie

Product: - Price: -

So, are IDataReader.GetName(i) and IDataReader.FieldCount safe to use when they have no results?


Solution

  • actually i just tested this my self, executing a reader against an empty set. Then without calling Read(); i successfully red the FieldCount, and GetName(i) for all columns while the data reader had 0 rows.