visual c# - How to get a column with a name from a DataTable ?

  • I stored a result set from an sql query into a DataTable. I want to get a DataColumn with a particular name into a DataColumn object. How do I do it ?

    Pseudocode -

    DataTable dt = Already set. Don't worry about it.

    string columnName = "Address";

    DataColumn col = dt.getColumn(columnName)

    Can you show me how this would be done in C# ?

  • DataColumn col = dt.Columns[columnName];

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply