Checking to see if a column exists in a data reader [duplicate]
I ended up finding a solution using the reader.GetName(int) method. I created the below method to encompass the logic. public bool ColumnExists(IDataReader reader, string columnName) { for (int i = 0; i < reader.FieldCount; i++) { if (reader.GetName(i).Equals(columnName, StringComparison.InvariantCultureIgnoreCase)) { return true; } } return false; }