1

When should I use DataSet instead of DataReader?

When I must use DataSet instead of DataReader?

When should I use data in a disconnected fashion?

When I must use data in a disconnected fashion?

N.B. I am not asking which is better. I need to know the appropriate scenarios of the use of DataSet. I am programming in .net for couple of years but I never seriously needed it.

user366312
  • 16,949
  • 65
  • 235
  • 452

2 Answers2

2

One scenario, When you want to pass data from one layer to another layer of your application you could use dataset. For more information Dataset and DataReader

Nirlep
  • 566
  • 1
  • 5
  • 13
0

A DataSet holds all of the needed data records in memory, whereas a DataReader reads records from a data connection one record at a time.

DataSets are commonly filled with data using DataReaders.

Use a DataReader when you need a high-performance, forward-only reader.

Use a DataSet when you need to do something that requires all of the data to be present at once, such as serialization or passing data between tiers. However, as others have pointed out, using List<T> rather than a DataSet object provides better separation of concerns between tiers.

See http://articles.sitepoint.com/article/dataset-datareader and http://msdn.microsoft.com/en-us/magazine/cc188717.aspx for more info on this.

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
  • It should be noted that DataSets can be loaded with DataReaders (I don't know a use case outside of proving that it can be done). – jrcs3 Oct 04 '09 at 23:10
  • I think you have it backwards. DataReaders are forward only and higher performance than DataSets, which are more focused on holding all of the data at once. I also prefer sending List between tiers. It keeps the domains more cleanly segregated. – Andy_Vulhop Apr 26 '10 at 17:20