I’m trying to get the column names using the code below but it returns a weird stuff… It returns a lot of “properties” (including the column name), all I want is a list of the columns names in the resultset. Am I doing something wrong ?
reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly);
DataTable schema = reader.GetSchemaTable();
DataRow myField = schema.Rows[0];
//For each property of the field...
foreach (DataColumn myProperty in schema.Columns)
{
host.WriteLine("##--> " + myProperty.ColumnName + " = " + myField[myProperty].ToString());
}
Thanks in advance people 🙂
Miloud B.
Note: I am writing this code without IDE. Please be kind.