Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Answers
If a DataReader holds one record at a time, then why...
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
Timothy
15y
4.3k
1
Reply
My understanding is that a DataReader can only hold one record in memory
at any given time and has to keep the connection to the database open to read subsequent records in a forward only manner.
How is it then that I can bind a dataReader to a DataGrid and display multiple rows?
I just don't get it. I currently have this code:
DbDataReader ddr = GetMetaClasses();
GridView1.DataSource = ddr;
GridView1.DataBind();
GetMetaClasses executes this stored procedure:
SELECT * FROM MetaClasses;
This is what my page displays:
ID
Name
FriendlyName
MetaClassType
1
NewsItems
News
Article
2
ClientPage
Client Page
Page
I don't understand how binding to the dataReader would work successfully and show all the results from the query if a dataReader can only hold one record in memory. Can someone please explain?? Thanks in advance!
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Advanced Sql to Dataset query
DataRow and Int.Parse