DataReader Vs DataView

(OleDbDataReader Vs SqlDataReader)

What are the main differences between DataReader   Vs   DataView  ?

Can I perform a Filter on DataReader? I have a list of 1000 records that I need to perform multiple Filters on a Loop. Would DataView be faster?
LVL 1
dennisdominicAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ddayx10Commented:
You probably want to use DataView for this operation.

In a datareader you basically get one shot at the data. You open a connection, feed it a query, the results are returned one line at a time through the datareader. As you read a line you can check values, store them somewhere, do whatever with that one line, but you only have access to that particular row. You can build an object like a table or list or even just plug the datareader in as the datasource for an object like a gridview. You cannot perform a filter straight on the datareader because you only have access to one row at a time. You could however make an object with a reader and manipulate it after the reader was finished.

A DataView is going to store the entire query results in it's entirety. You can manipulate it over and over getting the various results you want. The only slight disadvantage would be that this is a larger object (obviously) and so uses a bit more resources. I wouldn't think that would affect your consideration here. The DataView is made for what you are trying to do.

I would use the datareader if I was binding to an object and modifying objects in its databound event per se. If I wanted to manipulate the data and bind it to several objects based on the filter I gave it I would use the dataview instead of having to query the database multiple times.


???
0
lppperesCommented:
Hi dennisdominic,
In first place, DataReader is a specialized class that you found in each data provider, and DataView is a generic class to hold data in memory.
Operations like filter and sort are only possible in DataView.
Take a look at this forum. I think it may help you.
http://www.velocityreviews.com/forums/t86413-dataview-vs-datareader.html
0
dennisdominicAuthor Commented:
I'm going to award points, but am I correct to say...
DataReader - a specialized class just for reading data, forward only, and mainly used for populating objects such as gridview.
DataTable - a table that resides in the memory.
DataView - used to represent a subset of data from a DataTable. In order to use DataView, I need to run it against a DataTable?
DataSet - a collection of DataTable.
More information here.
http://www.experts-exchange.com/Programming/Languages/.NET/Q_20614250.html?query=DataSet+DataTable+DataView&clearTAFilter=true 
0
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

ddayx10Commented:
Award points not important...was a simple question just threw my $.02 at... looks like you have a better summary than any given :)

I would make sure you weren't confused about your summation of DataView. I would just say that yes you use a DataTable to create a DataView, but once it's created you don't need the table anymore and can filter the DataView in a myriad of ways. So you don't need the table as a seperate entity anymore.

Here is an example of where I made a DataView (for someone else's needs) and they wanted to just keep the DataView in session and use it again later for sorting, and re-binding.
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_24534302.html

http://msdn.microsoft.com/en-us/library/system.data.dataset.aspx
DataSet: Collection of DataTable objects. In memory. Can perform relational queries against tables inside DataSet.

http://msdn.microsoft.com/en-us/library/system.data.datatable.aspx
DataTable: In memory representation of a dbo or other table. Can filter into an array using select method. Interestingly can use a datareader to read. Also used to make a dataview.

http://msdn.microsoft.com/en-us/library/system.data.dataview.aspx
DataView: Used to create a customized view of a DataTable. Has methods and properties for filtering of that DataTable.

There's $.02 more cents worth :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ddayx10Commented:
I would mention to look at the menu on the left for those links. You will be able to look at the properties, methods, and events for these object. Even a quick glance through them can be pretty enlightening.
0
dennisdominicAuthor Commented:
very comprehensive.. more than I can digest, but I guess I need to try it out to understand. Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.