0

If we select a large number of rows and use an SqlDataReader, will it return the rows as they come or will it wait until the operation is complete?

This is with C#.net

asked Jul 28, 2010 at 15:01

2 Answers 2

1

It'll return the rows as they come. Each time you call SqlDataReader.Read(); the next row is retrieved from the client's network buffer. Only one row is held in memory on each Read().

// Starts getting the data from the query 
IDataReader reader = cmd.ExecuteReader(behavior); 
// Calling .Read() will get the next result from the client network buffer
while (reader.Read())
{
 // Do something with the row data
}

More information here.

answered Jul 28, 2010 at 15:03
Sign up to request clarification or add additional context in comments.

1 Comment

is saying that it will return them all at once.
0

They are streamed. If you review the "remarks" section it states that certain properties can only be safely read once the reader closes. If the complete result set was known prior to starting, these properties would be safe to read while the reader was open.

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.aspx

answered Jul 28, 2010 at 15:10

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.