With C# and SQL Server 2005 and by using DbConnection.GetSchema()
method, I want to get all a table's columns (not of views) only. I have found two collection names related to this
Columns
that returns table and views' columnsViewColumns
returns all the view's columns
Neither of above two returns table columns only, nor they have any property to filter Table-columns.
Any help is respected.
I don't see any easy way to do this with this particular API you're trying to achieve this with - but why not just use a query like this to get your information?
Just load that into a
SqlCommand
and execute it against the open connection you have and read the result into someDataTable
or other structure for your use. This gives you only table columns - and all of them.