Re: Why does a DataReader continue after losing connection?



Chris wrote:
From just about everything I have read, a DataReader reads only one
record at a time from a database and only caches that one record in
the client's memmory. However, a colleague of mine noted that this is
not exactly the case and proceeded to demonstrate this to me by
debugging through his code and breaking on a DataReader.Read() loop.
He then pulled the network cable from his computer as the database was
on a networked server and proceeded debugging through his code. To my
amazement, the DataReader continued to Read additional records. He
was using a SqlDataReader. Can someone explain this behavior to me?

The best I can come up with is this post on MSDN:
http://msdn2.microsoft.com/en-us/library/haa3afyz(vs.71).aspx

Which states "Results are returned as the query executes, and are
stored in the network buffer on the client until you request them
using the Read method of the DataReader."

So, is a DataReader storing more than one record on the client
computer? What exactly is the article referring to as the network
buffer? An example would be helpful.

Thanks,

Chris

The DataReader processes one record at a time, but the underlying database driver has a fixed size buffer that it uses to read records from the database. When reading, it gets the number of records that fits in the buffer.

The buffer is (IIRC) usually 8kb, so if your records are by average 800 bytes it will read about ten records at a time.

--
Göran Andersson
_____
http://www.guffa.com
.



Relevant Pages

  • Re: Under the hood of DataReader
    ... DataReader is provider-specific; we only provide guidelines of what would be ... sending rows to the client over the network in packets. ... we'll eventually have a packet on the client buffer ...
    (microsoft.public.dotnet.general)
  • Re: Under the hood of DataReader
    ... DataReader is provider-specific; we only provide guidelines of what would be ... sending rows to the client over the network in packets. ... we'll eventually have a packet on the client buffer ...
    (microsoft.public.dotnet.framework.adonet)
  • Why does a DataReader continue after losing connection?
    ... debugging through his code and breaking on a DataReader.Readloop. ... He then pulled the network cable from his computer as the database was ... the DataReader continued to Read additional records. ... is a DataReader storing more than one record on the client ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Xbox Extender giving network congestion errors
    ... Given the behavioral change you saw with changing your network setup, ... Regarding slow mo playback - next time you see video enter this mode, ... this doesn't sound like buffer depletion; what I would expect you to ... It corrects itself in a really ...
    (microsoft.public.windows.mediacenter)
  • Re: TCPBEUI misbehaving
    ... >> I try to analyse problems on my network. ... The wrkheuristics parameter sets a variety of requester fine-tuning ... 9 buffer small read and write requests until the buffer is full ... 27 force correct open mode when creating files on a core server (reserved ...
    (comp.os.os2.setup.misc)