I\'m generating a csv file from an SqlDataReader, however it is not writing the column names, how can I make it write them? The code I\'m using is as follows:
You can use the SqlDataReader.GetName method to get the name of a column, like this:
SqlDataReader.GetName
for(int i = 0; i < reader.FieldCount; i++) { string columnName = reader.GetName(i); }