I am learning ADO.Net. I read this line:-
DataReader is "connected" approach and dataset is "disconnected" approach
From this sentence I have reached to this conclusion that in data reader we need to establish the connection to the database while in dataset we do not need to establish the connection to the data base.
But how without establishing the connection one can access data.I know I am not getting the exact meaning.
Please any one can tell me the exact meaning with example.
connected data needs connection to be created to access hence slower while disconnected is in memory data that's faster access. to access connected data you use ADO.NET whereas for disconnected you do not use. disconnected-data can be accessed from multiple tables in a dataset. connected- .
The connected Approach (Data Reader) is a better choice for applications that require optimized read-only and forward-only access to data such as binding to a Data Grid control. The sooner the data is off-loaded from the Data Reader and the connection is closed the better the application performance.
A disconnected environment is one in which an application is not directly connected to a data source. Data is stored in datasets and manipulations are performed there. After the data has been modified in the dataset, the changes are updated to the database.
As mentioned earlier, ADO.NET supports two different programming environments: connected and disconnected. The connected environment provides forward-only, read-only access to data in the data source and the ability to execute commands against the data source.
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
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With