Click here to Skip to main content
15,879,348 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
Which one is best to use in web application of C#?
Either DataSet or DataReader
Posted
Updated 20-Apr-11 3:56am
v2

DataReader is a fast-forward only reader, where DataTable and DataSet represents one or more table of in-memory data.

It depends on your need in your web app. If you have to cache your data result. The use DataTable.
 
Share this answer
 
 
Share this answer
 
There is nothing like best. It all depends on what your requirements are. If all you need is to display something, there is no reason to go for a DataSet. But if you need to do updates and inserts as well, you may use DataSet.

BTW DataAdapter uses DataReader to populate the DataSet although it is bit irrelevant.

OffTopic: There is nothing called C#.Net.
 
Share this answer
 
v2
it depends on your need

if you want to return multiples tables from the database use
DataSet
 
Share this answer
 
                                  DataSet :-

The DataSet actually uses a DataReader to populate itself.
Dataset is an inmemory representation of data .By using Dataset we can not make continous connection with the database.we can modify data in the Dataset and call accept changes()
method that will save the updations in the database .Webservices Generally uses DataSet Only

dataset is slower than datareader beacause dataset will maintain multiple tables,relations,data views.


                                  Data Reader :-

A DataReader is a lean, mean access method that returns results as soon as they’re available, rather than waiting for the whole of the query to be populated into a DataSet. This can boost your application performance quite dramatically, and, once you get used to the methodology, can be quite elegant in itself.

DataReader is mainly used for readonly and forward only related data
it is very fast compared to dataset.

if you are storing only one table then go with datareader other wise use dataset.

Refer below link it will gives you detail information :

http://www.techrepublic.com/article/which-is-best-for-you-datareader-or-dataset/5066984
 
Share this answer
 
v4
Comments
Ankur\m/ 20-Apr-11 9:37am    
plagiarism it is - http://blogs.sitepoint.com/dataset-datareader/
BobJanova 20-Apr-11 9:39am    
Not even plagiarising a good source who can write English? For shame ;)
Ankur\m/ 20-Apr-11 9:53am    
:)
Ah and he votes my answer down. :doh:
Ankur\m/ 20-Apr-11 9:57am    
You know what, I could have "reported" your answer for plagiarising someone's work and your answer would have been removed.
But I just voted it down giving you a reason. You could have updated your answer mentioning the link from where you copied it or writing your own explanation. I sure would have changed my vote.
I was searching for the same i got he following solution from stack overflow. I am also attaching additional link at the bottom of the page.

It depends on your needs One of the most important differences is that a DataReader will retain an open connection to your database until you're done with it while a DataSet will be an in-memory object. If you bind a control to a DataReader then it's still open. In addition, a DataReader is a forward only approach to reading data that can't be manipulated. With a DataSet you can move back and forth and manipulate the data as you see fit.

Some additional features: DataSets can be serialized and represented in XML and, therefore, easily passed around to other tiers. DataReaders can't be serialized.

On the other hand if you have a large amount of rows to read from the database that you hand off to some process for a business rule a DataReader may make more sense rather than loading a DataSet with all the rows, taking up memory and possibly affecting scalability.

In order to further understand the difference, i suggest you read this article as well
 
Share this answer
 
Comments
Dholakiya Ankit 13-Sep-13 8:28am    
its 2 year ago question

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900