Become Joomla Developer

DataSet vs. DataReader

DataReader

  1. A dataReader is specific to a data provider(for example, SqlDataReader, OdbcDataReader, and OleDbDataReader).
  2. The data retrieved through a DataReader is read-only.
  3. The data retrieved through a DataReader is forward-only. Once the data has been cycled through, the DataReader must be closed and re-created in order to reaccess the data.
  4. A DataReader presents data through a direct connection to the data source. Only one row of data is stored in memory at any one time.
  5. A DataReader takes up few IIS and memory resources but annexes the database connection until it’s closed.
  6. A DataReader lasts as long as the connection to the database is open. It can’t be persisted in a cookie or a session variable.
  7. Columns in a DataReader are referenced by index or name.
  8. A DataReader has no concept of primary keys, constraints, views, or any other relational database management system concepts, except rows and columns.
  9. You can’t update a data source through a DataReader.
  10. A DataReader connects to only one data source

DataSet

  1. The DataSet class isn’t a part of any data provider. It’s specific to .Net only. However, the DataAdapter used to fill the DataSet with Fill( ) is specific to a data provider(for example, SqlDataAdapter, OdbcDataAdapter and OleDbDataAdapter).
  2. The data retrieved through a DataSet is read-write.
  3. You can work with data in a DataSet in any order you choose as many times as you like.
  4. A DataSet stores all the data from the data source in memory at once.
  5. A DataSet takes up a lot more IIS and memory resources to store all the data, but it doesn’t hold up a database connection until it’s closed. The connection needs to be open only when Fill( ) is called.
  6. A DataSet lasts only until the page is reloaded(posted back), unless it’s somehow persisted(for example, in a session varriable).
  7. You can reference columns in a DataSet by name, but you must also name the DataTable and identify the row(index) that contains the column.
  8. A DataSet contains a collection of DataTable objects. A primary key may be set for each DataTable, and relationships and constraints may be established between them.
  9. You can make changes to data in a DataSet, and then send those changes back to the data source.
  10. A DataSet can be filled with Fill( ) from multiple data sources but, once the data is retrieved, is not connected to any of them.

Suggestion | Contact US | About US | Term of Use | Privacy Policy | Advertiseing