473,405 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Why does a DataReader continue after losing connection?

>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/lib...yz(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

Jul 17 '07 #1
2 2135
"Chris" <C_********@hotmail.comwrote in message
news:11**********************@22g2000hsm.googlegro ups.com...
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.
I'd be suprised if some sort of cache didn't exist.

Michael
Jul 17 '07 #2
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/lib...yz(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
Jul 17 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Yasutaka Ito | last post by:
Hi, My friend had a little confusion about the working of DataReader after reading an article from MSDN. Following is a message from him... <!-- Message starts --> I was going thru DataReader...
5
by: Joel Reinford | last post by:
I am attempting to verify whether a datareader is closed by calling the databind on a control. for example (fake code) Dim rdr as SqlDataReader rdr = mycommand.executeReader... ...
20
by: Mark | last post by:
Hi all, quick question , a DataView is memory resident "view" of data in a data table therefore once populated you can close the connection to the database. Garbage collection can then be used to...
4
by: Maziar Aflatoun | last post by:
Hi everyone, I am working on the 'Delete' section of my program. What I need to do is query my database and for every ID that it finds I want to remove a file+ID.jpg from my file folder and...
17
by: Alan Silver | last post by:
Hello, I have a generic method in a utility class that grabs an sqldatareader and returns it. Due to the fact that (AFAIK), you can't close the database connection before you've read the data,...
3
by: jason | last post by:
Hi, {asp .net 1.1, sp 2) I am facing problems with multi users accessing the same page. There is a datagrid in the webform. The "datareader already opened error/ object reference not found"...
20
by: fniles | last post by:
I am using VB.NET 2003, SQL 2000, and SqlDataReader. As I read data from tblA, I want to populate tblB. I use SQLDataReader for both tables. I do not use thread. When I ExecuteReader on tblB, I...
10
by: jimmy | last post by:
Hi again, sorry for posting two questions so close together but im working on a school project which is due in soon and running into some difficulties implementing the database parts. I have the...
3
by: Johnny Jörgensen | last post by:
I've got an error that I simply cannot locate: I've got a form in which I use a datareader object to read information from a db. After the read, I close the reader and I dispose of both the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.