<s>
In	O
ADO.NET	B-Device
,	O
a	O
DataReader	B-Language
is	O
a	O
broad	O
category	O
of	O
objects	O
used	O
to	O
sequentially	O
read	O
data	O
from	O
a	O
data	O
source	O
.	O
</s>
<s>
DataReaders	B-Language
provide	O
a	O
very	O
efficient	O
way	O
to	O
access	O
data	O
,	O
and	O
can	O
be	O
thought	O
of	O
as	O
a	O
Firehose	O
cursor	B-Language
from	O
ASP	B-General_Concept
Classic	I-General_Concept
,	O
except	O
that	O
no	O
server-side	B-Application
cursor	B-Language
is	O
used	O
.	O
</s>
<s>
A	O
DataReader	B-Language
parses	O
a	O
Tabular	B-Protocol
Data	I-Protocol
Stream	I-Protocol
from	O
Microsoft	B-Application
SQL	I-Application
Server	I-Application
,	O
and	O
other	O
methods	O
of	O
retrieving	O
data	O
from	O
other	O
sources	O
.	O
</s>
<s>
A	O
DataReader	B-Language
is	O
usually	O
accompanied	O
by	O
a	O
Command	O
object	O
that	O
contains	O
the	O
query	O
,	O
optionally	O
any	O
parameters	O
,	O
and	O
the	O
connection	O
object	O
to	O
run	O
the	O
query	O
on	O
.	O
</s>
<s>
There	O
is	O
no	O
DataReader	B-Language
class	O
in	O
ADO.NET	B-Device
,	O
but	O
there	O
are	O
a	O
number	O
of	O
classes	O
that	O
implement	O
the	O
IDataReader	O
interface	O
:	O
</s>
<s>
DataReaders	B-Language
have	O
a	O
small	O
footprint	O
and	O
good	O
performance	O
because	O
each	O
is	O
tailor-made	O
to	O
the	O
task	O
at	O
hand	O
,	O
however	O
this	O
makes	O
it	O
more	O
difficult	O
to	O
write	O
an	O
application	O
that	O
can	O
be	O
moved	O
from	O
one	O
backend	O
data	O
source	O
to	O
another	O
.	O
</s>
<s>
Some	O
provider-specific	O
DataReaders	B-Language
expose	O
types	O
used	O
by	O
the	O
underlying	O
database	O
-	O
for	O
example	O
,	O
values	O
can	O
be	O
null	O
in	O
Microsoft	B-Application
SQL	I-Application
Server	I-Application
,	O
but	O
not	O
in	O
the	O
.NET	B-Application
Framework	I-Application
prior	O
to	O
version	O
2.0	O
.	O
</s>
<s>
When	O
using	O
a	O
DataReader	B-Language
to	O
retrieve	O
data	O
,	O
the	O
developer	O
can	O
choose	O
to	O
read	O
field	O
values	O
in	O
strongly	O
typed	O
manner	O
(	O
example	O
:	O
)	O
or	O
a	O
weakly	O
typed	O
manner	O
,	O
returning	O
then	O
as	O
s	O
(	O
example	O
:	O
)	O
.	O
</s>
<s>
Numeric	O
values	O
in	O
the	O
database	O
can	O
translate	O
to	O
several	O
.NET	B-Application
types	O
:	O
,	O
or	O
.	O
</s>
<s>
This	O
is	O
also	O
true	O
when	O
you	O
use	O
the	O
right	O
type	O
,	O
but	O
encounter	O
a	O
value	O
(	O
this	O
can	O
be	O
avoided	O
by	O
using	O
the	O
boolean	O
function	O
of	O
the	O
DataReader	B-Language
class	O
)	O
.	O
</s>
<s>
Further	O
,	O
with	O
some	O
effort	O
,	O
the	O
programmer	O
can	O
extract	O
the	O
value	O
into	O
a	O
variable	O
of	O
the	O
proper	O
type	O
by	O
using	O
the	O
or	O
methods	O
of	O
the	O
DataReader	B-Language
.	O
</s>
<s>
A	O
DataReader	B-Language
can	O
in	O
some	O
cases	O
be	O
used	O
in	O
place	O
of	O
a	O
DataTable	O
,	O
however	O
many	O
programmers	O
have	O
experienced	O
connection	O
bloat	O
when	O
following	O
this	O
approach	O
.	O
</s>
<s>
A	O
DataReader	B-Language
can	O
only	O
be	O
used	O
against	O
an	O
(	O
already	O
)	O
open	O
database	B-General_Concept
connection	I-General_Concept
;	O
that	O
connection	O
is	O
n't	O
closed	O
until	O
the	O
DataReader	B-Language
's	O
method	O
is	O
called	O
.	O
</s>
<s>
If	O
an	O
exception	O
is	O
thrown	O
while	O
the	O
data	O
is	O
being	O
processed	O
,	O
for	O
example	O
as	O
described	O
in	O
Strong	O
and	O
weak	O
typing	O
,	O
above	O
,	O
the	O
method	O
will	O
never	O
be	O
called	O
if	O
the	O
developer	O
writes	O
code	O
explicitly	O
declaring	O
and	O
disposing	O
the	O
DataReader	B-Language
without	O
the	O
use	O
of	O
a	O
-	O
block	O
.	O
</s>
<s>
The	O
C#	B-Application
construct	O
is	O
a	O
good	O
way	O
to	O
avoid	O
this	O
problem	O
,	O
as	O
shown	O
below	O
in	O
the	O
code	O
example	O
.	O
</s>
