TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Timothy
NA
2
0
If a DataReader holds one record at a time, then why...
Aug 4 2009 12:02 AM
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!
Reply
Answers (
2
)
Win $500 Cash
Drag and Drop the controls at runtime in ASP.NET application