yariv
yariv

Reputation: 1

How to get field name from a SQL statement using c#

I want to retrieve field names from a SQL statement. For example, if I have:-

SELECT a, tbl.b, [tbl.s] 
FROM tbl

I'd like to retrieve::

I'd need to do it via any database object.

Upvotes: 0

Views: 1279

Answers (1)

Kevin Worthington
Kevin Worthington

Reputation: 457

Using the SqlDataReader Class you can do:

Reader.GetName(columnNumber)

and that will return the column name.

Upvotes: 2

Related Questions