I am writing some tool which has to retrieve column names of the retrieved data set when any query is applied to it.
If you're familiar with phpMyAdmin, you would realize the SQL pane does what is it runs your query and shows result with the column names. I wonder how hard the query would be, it always results in column names and what's actually the programming behind the scene? Is it like, it analyzes the query and then find table names from it and then first retrieve column names using query show columns from table-name and then the data?
Is there any better way?
UPDATED
Sorry for incomplete information, I think I must say I am using MySQL connector for .NET and am using C#.
解决方案
Your columns are part of the metadate of the DataReader or DataTable that you load in c#
From MSDN for DataTable:
private void PrintColumnNames(DataSet dataSet)
{
// For each DataTable, print the ColumnName.
foreach(DataTable table in dataSet.Tables)
{
foreach(DataColumn column in table.Columns)
{
Console.WriteLine(column.ColumnName);
}
}
}