I want to get a list of the field names returned from a sql statement. This can be done using a sql statement or some c# parsing code to parse the statement as a string. Can this be done easily without writing a complex parser?
For example I may want to return
name, field2, field3
from
SELECT a.field1 as name, a.field2, b.field3 FROM A INNER JOIN B ON A.Id = B.FkId
If you are asking about using SqlClient components, such as the SqlDataReader Class, you can use the
Reader.GetName(columnNumber)
Method to return the column name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With