Quickest way to read from a datareader

  • Thread starter Thread starter =?iso-8859-1?Q?S=F8ren_Lund_Jensen?=
  • Start date Start date
?

=?iso-8859-1?Q?S=F8ren_Lund_Jensen?=

Hello,

What is the quickest way to read from a DataReader? Any properties I
can set to speed up the default behavior?
 
Hello,

What is the quickest way to read from a DataReader? Any properties I
can set to speed up the default behavior?

Read into an array using GetValues() will help a lot, and then read
the values from the array.

Also do not use IsDbNull(ordinal), but test if myDataReader[ordinal]
== System.DbNull.Value. This is much faster.

If you do not know the ordinal values of the fields you're fetching
and you're fetching multiple rows, determine the ordinals once, then use
these ordinals instead of the names, which is much faster. But again, using
the GetValues() feature is much faster than reading the values individually.

Frans.
 
Back
Top