I have a simple routine that takes a SELECT statement and uses a DataTable.
I use the same SELECT statement and pass it through a routine to generate an array of column names and data types.
As long as the SELECT statement is simple
e.g SELECT Firstname,Secondname...etc...
... my routine can add the column information to my array
However, if the SELECT statement is a little more complex
e.g. SELECT Firstname,Secondname AS Surname... etc...
... my routine will fall over because Surname is not a column name.
More complexity can occur when you factor in subqueries and aggregate columns.
I am looking for a more elegant approach if there is one to acquire any base column names from a SELECT statement?