DataTableReader::GetOrdinal Method (String^)
Gets the column ordinal, given the name of the column.
Assembly: System.Data (in System.Data.dll)
Because most of the methods provided by the DataTableReader class must be provided with an ordinal column number, you can use the GetOrdinal method to retrieve the column number, given the name of the column.
GetOrdinal performs a case-sensitive lookup first. If it fails, a second case-insensitive search is made. If the column number is not found an IndexOutOfRangeException is thrown.
GetOrdinal is kana-width insensitive.
Because ordinal-based lookups are more efficient than named lookups, it is inefficient to call GetOrdinal within a loop. Save time by calling GetOrdinal one time and assigning the results to an integer variable for use within the loop
If you have only a column name, in which case the column name is user supplied, and you must retrieve information from the column, you can use a procedure like the following to extract the required information. In this example, the procedure accepts a column name and returns the data that is contained within that column for the current row in the DataTableReader :
Available since 2.0