I am learning ADO.Net. I read this line:-
DataReader is \"connected\" approach and dataset is \"disconnected\" approach
From this
In classic ADO the RecordSet
object could work both in connected and disconnected mode. In Ado.Net there are two separate types available to cater to each of these scenarios - IDataReader and DataSet
Connected Mode: remains connected to the underlying data source while traversing in a forward-only streams of result sets.
Disconnected Mode: the resultset retrieved is kept in memory and the connection to the DB is no longer needed for traversal.
This MSDN article further compares the two objects and discusses their individual merits a lot better than I will be able to explain here.
Think DataSet as in memory database, it contains DataTables and contain tables data (all or subset of data based on Select query) and even maintain relations among tables. On the DataSet you can perform update/delete operations, it will be synched to database through DataAdapter object. so to display data it does not need to be connected to database All time as DataReader, which needs to be connected to database whenever you want to display data.
Disconnected = Make Connection , Fetch Data , Close Connection
Connected = Make Connection , Keep Connection alive , Close Connection when close is called.
For more information , please see the link on MSDN
The ADO.net architecture, in which connection must be kept open till the end to retrieve and access data from database is called as connected architecture. Connected architecture is built on the these types - connection
, command
, datareader
The ADO.net architecture, in which connection will be kept open only till the data retrieved from database, and later can be accessed even when connection to database is closed is called as disconnected architecture. Disconnected architecture of ADO.net is built on these types - connection
, dataadapter
, commandbuilder
and dataset
and dataview
.
Connected architecture: In connected model we can connect any application to database and stays connected to the database system even when it is not using any database operations. For this architecture, we use Connection
, Command
and DataReader
.
Disconnected architecture: In disconnected model we connect any application to database until we call the close method. In this architecture we use DataSet
and DataAdapter
.
Connected Architecture : For Every request , Hit the Database , Fetch the DATA and bring Back. you can perform only Read Operation.Connection should be always OPEN.Uses Data Reader
Dis Connected Architecture : Fetch the Entire Data at once and now perform whatever operation you want to perform. Isert / Update / Delete. No need for the connection to be always OPEN.Uses Data Set , Data Adapter