10.12. Improving DataReader Performance with Column Ordinals

Problem

You want to use column ordinals rather than column names to retrieve data from a DataReader to improve application performance and without hardcoding the ordinal values.

Solution

Enumerate the column ordinals using the GetOrdinal() method and use those values to retrieve data from the DataReader.

The solution uses a DataReader to retrieve and output the column ordinals for result set columns—ContactID, FirstName, and LastName...