To acess data from a Data Reader, we mostly use the column / field name to retrieve data from a field .
And we use field name instead of index atlest for the following two reasons :-
1. using field name instead of index makes the code more readable 2. if the column order changes on the DB (say a new column is inserted), we don’t need to change anything inside the code . But did you know that – reading value from datareader using field name is slower than using index ?
|
There is a work around to solve the above problem as well as to improve performance Ex. : |