DataReader, DataAdapter & DataSet - When to use?

ADO.NET offers two central Data Access Components. In this Article we will discuss about their features and when to use what.

ADO.NET provides two central Data Access Components. The excellent thing is that, they are common across all Databases, be it SQL Server or other competitive databases. Its only the namespace to be used, that differs, while using a Database other than SQL Server.

The two Data Access Compnents are:


1. DataSet

2. The .NET data provider, which is a set of components including the Connection, Command, DataReader, and DataAdapter objects.


Its common that the doubt arises on when to use DataReader and DataAdapter, DataSet.

The thumb rule I would suggest is,


1. If your Data access operations is mainly fetching and displaying the records and doesnt involve insert/update/delete statements and other manipulations (forward only, read only) actions, go for the DataReader.


DataReader offers a forward only read stream of access to the records. It is very useful in cases where we just grab the data from the database to display in DataGrid, Label and other Webcontrols.

However, DataReader requires the connection with the database open until its operation is completed.


2. If your Data access operations extend to as simple as an Insert/Update/Delete statement to as complex as using it as a return type from a web service, go for the DataSet. The DataSet has the following advantages.


i. Complex Data type supporting numerous methods such as ReadXML which reads new XML data to form a dataset, WriteXML which provides an XML format of the existing data, etc.,

ii. Works on the disconnected architecutre i.e. The connection doesnt need to be on for the DataSet to perform the manipulations and other actions and is required only at the time of Updating the records to the Database Table.

iii. Provides an In-memory representation of the Data. Can contain one or more DataTable objects that have primary key, foreign key, and constraints between them and can enforce constraints such as unique or be configured to ignore them
iv. Has Individual elements such as DataTable, DataRow and DataColumn to access specific values.

v. While using DataSet and DataAdapter, you don't need to explicitly open the connection. DataAdapter automatically opens and closes the connection as and when required.

Hope it provided some insight into DataReader, DataSet and DataAdapter.

Thanks.

posted @ Monday, April 25, 2005 7:54 AM

Print

Comments on this entry:

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Suman at 3/10/2006 10:27 AM
Gravatar
Information you have provided is fabulous

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Jon Brune at 3/24/2006 6:53 PM
Gravatar
Great, thanks for the information.

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Deepika at 4/7/2006 3:41 PM
Gravatar
Provided info is too good, it is explained in a very efficient and simple manner.

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Ali Imran Ahmad at 5/3/2006 7:09 AM
Gravatar
Plz Describe more about the Data Set and Data Adapter.This is an ecellent article about the data reader and dataset.

# re: DataReader, DataAdapter & DataSet - When to use?

Left by subburaj at 6/22/2006 2:05 PM
Gravatar
doubts cleared by this article in a simple as well as greater manner

# re: DataReader, DataAdapter & DataSet - When to use?

Left by kesavan at 6/29/2006 5:04 AM
Gravatar
Its really very useful for the beginnners who are all working in ADO.NET

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Sujith MS at 8/9/2006 1:06 PM
Gravatar
Really explained the use of datareader and dataset. Thanks for the information.

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Pravin P at 1/16/2007 8:13 AM
Gravatar
Provided info is too good, it is explained in a very efficient and simple manner.

# re: DataReader, DataAdapter & DataSet - When to use?

Left by konda reddy at 2/26/2007 12:56 PM
Gravatar
The information provided by u, is simly superb because a person with mere knowledge can understand it easily.

# re: DataReader, DataAdapter & DataSet - When to use?

Left by sachin at 1/16/2008 10:47 PM
Gravatar
Awesome.... Short and sweet information..

# re: DataReader, DataAdapter & DataSet - When to use?

Left by gayathri at 3/8/2008 12:26 PM
Gravatar
Its very clear and simple,even the new learners can understand it.

# re: DataReader, DataAdapter & DataSet - When to use?

Left by rakesh at 4/2/2008 4:08 PM
Gravatar
its awesum

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Athula at 5/4/2008 8:50 PM
Gravatar
Thaks for the great help. It's so clear and understandable.

# re: DataReader, DataAdapter & DataSet - When to use?

Left by code0910 at 5/26/2008 12:45 PM
Gravatar
thanks for the information bro.. Keep it up.

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Rabia at 6/4/2008 5:10 PM
Gravatar
Thanks ,this information is very fabulous and easy .

# re: DataReader, DataAdapter & DataSet - When to use?

Left by kokilaNaresh at 6/5/2008 5:36 PM
Gravatar
As i am new to .net,the information you had given is very useful for me to proceed.
thank you

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Mahesh Khadse at 7/6/2008 6:52 PM
Gravatar
Thx for the greate help... :-))

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Bond James Bond at 7/25/2008 12:21 AM
Gravatar
the information given above is...MAHA FUUDDDUUUUU

# re: DataReader, DataAdapter & DataSet - When to use?

Left by JATIN 9855366988 at 7/25/2008 6:36 PM
Gravatar
GOOD INFORMATION

# re: DataReader, DataAdapter & DataSet - When to use?

Left by digish at 8/11/2008 3:35 AM
Gravatar
Thank you for the help

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Aniket at 8/17/2008 6:04 PM
Gravatar
Good article..

# re: DataReader, DataAdapter & DataSet - When to use?

Left by navnith at 8/23/2008 4:25 PM
Gravatar
i got to know the diff between them and their functonality after studying this thank u

# re: DataReader, DataAdapter & DataSet - When to use?

Left by coolcoder at 9/6/2008 1:29 PM
Gravatar
Wonderful explanation boss.
Thanks
coolcoder

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Atul Yadav at 9/17/2008 3:52 AM
Gravatar
All the operation can perform to the Data reader in Database then what is the use to the DataAdapterin connect to the database

# re: DataReader, DataAdapter & DataSet - When to use?

Left by vamc at 11/14/2008 5:59 PM
Gravatar
thanks for ur clear explanation......

# FREE SİSME BEBEK

Left by şişme bebek at 11/20/2008 1:30 PM
Gravatar
UU CUCUCUCUCUC

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Adeel Arshad at 1/26/2009 2:52 PM
Gravatar
i think it is the excellent for New people. in a very easy way.

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Ranganayaki at 2/6/2009 12:29 PM
Gravatar
It was of a very great help.

Thanks.

# re: DataReader, DataAdapter & DataSet - When to use?

Left by şişme bebek at 3/16/2009 1:19 PM
Gravatar
thanks very good webpage

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Anup at 3/21/2009 12:03 AM
Gravatar
The explanation is Wow!.

# re: DataReader, DataAdapter & DataSet - When to use?

Left by ITSolutions at 5/2/2009 8:23 PM
Gravatar
Extreamlly helpful.. this explanation is so precise and to point, I am blown away.

# re: DataReader, DataAdapter & DataSet - When to use?

Left by wukai at 5/14/2009 8:06 PM
Gravatar
Thanks , i am a chinese .
it 's a webpage .

# re: DataReader, DataAdapter & DataSet - When to use?

Left by TOSIF at 5/16/2009 10:44 AM
Gravatar
Plz Describe more about the Data Set , Data Adapter,DataSet

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Ajn at 6/1/2009 1:11 PM
Gravatar
Is there any way to fill datadapter by using datareader because if we have more than 1,000,000 records DataAdpter is to low.

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Ily at 6/3/2009 6:43 PM
Gravatar
much better, but you didnt mention whts use of data adapter, if you can perform everything through datareader and dataset, its mean data adapter only use to connect to database ......

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Ajz at 7/14/2009 1:42 PM
Gravatar
Awesome piece of information...Thanks

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Devang at 8/25/2009 12:32 AM
Gravatar
data adapter is used to link dataset & database...
because dataset can not fetch data directly from database...

# re: DataReader, DataAdapter & DataSet - When to use?

Left by sarban at 9/2/2009 1:17 PM
Gravatar
Thx for this wonderfull information

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Pankaj Pundir at 9/13/2009 4:42 AM
Gravatar
Thanks Dear Good Artical

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Rose at 9/14/2009 8:59 PM
Gravatar
Its good....

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Durga at 9/23/2009 7:01 PM
Gravatar
Thanks a lot.

# re: DataReader, DataAdapter & DataSet - When to use?

Left by Faheem-Pak at 10/15/2009 1:30 AM
Gravatar
Thank u very much to increase my knowledge. Great job

# re: DataReader, DataAdapter & DataSet - When to use?

Left by wpablow at 11/22/2009 3:49 AM
Gravatar
I´m not sure what´s the different between DataAdapter and Dataset. It´s not clean in the article and I was finding about that. Someone know the difference? Sorry by my english.

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345