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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top