Optimizing ADO.NET code
There are several ways to increase the performance of ADO.NET code in your Web or Windows forms applications:
- Using DataReader Versus DataSet
- Managing Database Connections
- Choosing Your Data Provider Wisely
- Using "SELECT *" Sparingly
- Avoiding Automatically Generated Commands
For an introduction to these ADO.NET optimizations, take a look at the "Optimizing ADO.NET Code" Section in Chapter 23 of Sams Teach Yourself ADO.NET in 24 Hours from Sams Publishing.
Using column ordinals in ADO.NET rather than column names to retrieve data from a DataReader will improve application performance without hard-coding the ordinal values. This can be done by enumerating the column ordinals using the GetOrdinal( ) method and using those values to retrieve data from the DataReader.
For details on improving DataReader performance with column ordinals, read Recipe 9.7 of ADO.NET Cookbook from O'Reilly Media.