Re: Why does a DataReader continue after losing connection?
- From: Göran Andersson <guffa@xxxxxxxxx>
- Date: Tue, 17 Jul 2007 13:15:04 +0200
Chris wrote:
record at a time from a database and only caches that one record inFrom just about everything I have read, a DataReader reads only one
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
.
- References:
- Prev by Date: Beginner question: How do I position controls in a GroupBox?
- Next by Date: <newbie> DataGridView question
- Previous by thread: Re: Why does a DataReader continue after losing connection?
- Next by thread: Windows DPI settings
- Index(es):
Relevant Pages
|