Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Datareader, DataAdapter, Dataset, DataView

Tags:

Can someone please explain the difference between a DataReader, a DataAdapter, a Dataset, and a DataView?

like image 242
Sunil Pal Avatar asked Aug 14 '11 05:08

Sunil Pal


People also ask

Can you explain the difference between a DataReader a DataAdapter a DataSet and a DataView?

Generally we will use ExecuteReader object to bind data to datareader. DataSet is a disconnected orient architecture that means there is no need of active connections during work with datasets and it is a collection of DataTables and relations between tables. It is used to hold multiple tables with data.

What is difference between DataReader and DataSet?

DataReader provides faster performance, but has read-only and forward-only access. DataSet, on the other hand, is high resource-consuming, but offers more control and a disconnected nature.

What is difference between DataReader and DataAdapter?

Using the DataReader can increase application performance both by retrieving data as soon as it is available, and (by default) storing only one row at a time in memory, reducing system overhead. A DataAdapter is used to retrieve data from a data source and populate tables within a DataSet.

What is the difference between DataView DataTable and DataSet?

DataTable means single table representation whereas a DataSet is a multiple table representation. That means by using DataTable we can hold only one single table from the database, if we use DataSet we can hold multiple tables at a time... DataView means view of data available in DataSet ...


1 Answers

Quickly,

  • a DataReader is a forward-only iterator over a set of results. It's usually the most efficient way to deal with records when you don't need random access (in other words you can't go backwards). It is "scalable" to any number of records, at least in terms of memory pressure, since it only loads one record at a time. One typical way to get a DataReader is by using the ExecuteReader method of a DbCommand.

  • a DataSet represents a set of DataTable objects. More often than not, it will just contain one table, but if you do a query with multiple SELECT statements, the DataSet will contain a table for each. Because this is an in-memory representation, you have to be careful about how much data you pull into a DataSet. You can "Fill" a DataSet using the Fill method of a DataAdapter.

  • a DataAdapter is a kind of "pipe" that funnels data from a DB engine into a DataSet. That's why you'll have one DataAdapter implementation for each DB provider type. One DataSet, many providers.

  • a DataView is like a virtual subset of a DataTable.

like image 176
harpo Avatar answered Oct 08 '22 03:10

harpo