Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2006

Tip: Looking for answers? Try searching our database.

SqlDataReader underlying data

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
narshe@gmail.com - 05 Mar 2006 19:49 GMT
I'm trying to figure out how the SqlDataReader works, and this is my
main question:

When SqlCommand.ExecuteReader() is called, are all rows of the query
returned immediately? This would mean the a call to reader.Read() would
just return the first row from the underlying data. Or does a call to
reader.Read() fetch the next row from SqlServer?

I've been digging through a watch of SqlDataReader, and can see that
the reader holds a row of data at a time. I would think it's getting
it's rows from the command, but I really can't find much else.
narshe@gmail.com - 05 Mar 2006 22:39 GMT
Ok. I found out a lot from this article:

http://msdn.microsoft.com/msdnmag/issues/04/06/datapoints/default.aspx

The reader is connected the whole time, and a call to DataReader.Read()
gets the next row from sql server.

I also noticed that ExecuteNonQuery and ExecuteScaler use the
DataReader to get their data. Does this mean there is one internal data
reader being used in SqlCommand, and a call to ExecuteReader just
returns that reader?

Another thing I don't get; what is the purpose of DataReader.Close()?
What exactly does this close? It doesn't close the connection. Does it
just set a flag so that calls to ExecuteReader/Scaler/NonQuery don't
try and start a new command sequence to sql server while in the middle
of one?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.