Just wondering what is best practice for getting the values of a datareader. For example:
I have been doing this:
MyValue = Dr('ColumnName')
But have noticed other people doing:
MyValue = Dr.GetString('ColumnName')
I am intested to know the benifits of the 2nd method
I’ve been using a wrapper that does a similar thing for a while that does the trick nicely.
The nice thing about this is the helper will return pre-defined defaults for NULL columns (this is configurable). I’ve got methods for all the main SQL data types.
To answer your question, the second method has some boxing / unboxing overhead but it would probably be a waste of your time to optimise this for a typical business application.