0% found this document useful (0 votes)
23 views

DataSet VS DataReader

The document compares DataSet and DataReader in ADO.Net. DataSet operates in a disconnected nature and fetches all data from the data source at once. It is suitable when data needs to be manipulated or navigated multiple times. DataReader is forward-only and connected, fetching one row at a time for lower overhead. It is suitable for displaying read-only data to users.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

DataSet VS DataReader

The document compares DataSet and DataReader in ADO.Net. DataSet operates in a disconnected nature and fetches all data from the data source at once. It is suitable when data needs to be manipulated or navigated multiple times. DataReader is forward-only and connected, fetching one row at a time for lower overhead. It is suitable for displaying read-only data to users.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

PART-9

DataSet VS DataReader
in ADO.Net
PRESENTER: MOHAMMAD ADIL
DataSet VS DataReader in ADO.Net
DATASET DATAREADER
• The DataSet class in ADO.Net • DataReader is a connection
operates in an entirely oriented service.
disconnected nature.
• DataReader is used to retrieve
• DataSet is a collection of in- read-only (cannot
memory tables. update/manipulate data back
to datasource) and forward-
only (cannot read
backward/random) data from a
database.
DataSet VS DataReader in ADO.Net
DATASET DATAREADER
• DataSet releases the data after • DataReader fetches the
loading all the data in memory. records from database and
stores in the network buffer
• DataSet fetches all the rows at
and gives whenever requests.
a time i.e. it fetches all data
from the datasource at a time • DataReader is like a forward
to its memory area. only recordset. It fetches one
row at a time so very less
network cost compare
to DataSet.
DataSet VS DataReader in ADO.Net
DATASET DATAREADER
• There is more system • As one row at a time is stored
overheads in DataSet as it in memory in DataReader it
fetches all the data from the increases application
datasource at a time in performance and reduces
memory. system overheads.
• In DataSet we can move back • As DataReader is forward only,
and forth and fetch records we can’t fetch random records
randomly as per requirement. as we can’t move back and
forth.
DataSet VS DataReader in ADO.Net
DATASET DATAREADER
• DataSet can fetch data from • DataReader fetches data from
multiple tables. a single table.
• Relationship between multiple • As DataReader can have data
tables can be maintained from a single table so no
in DataSet. relationship can be
maintained.
• Transactions are possible in
DataSet • DataReader is read only so no
transaction like insert, update
and delete is possible
DataSet VS DataReader in ADO.Net
DATASET DATAREADER
• DataSet is a disconnected • DataReader is a connected
architecture that automatically architecture: The data is
opens the connection, fetches available as long as the
the data into memory and connection with database
closes the connection when exists.
done.
• DataReader is a lightweight
• DataSet is a bulky object that object that requires less
requires lot of memory space memory space as compared
as compared to DataReader . to DataSet.
DataSet VS DataReader in ADO.Net
DATASET DATAREADER
• DataSet can be serialized and • DataReader can't be serialized.
represented in XML so easily
• DataReader requires connectio
passed around to other tiers.
n to be open and close
• DataSet automatically handles manually in code.
the connection.
• DataReader will be the best
• DataSet is best suited where choice where we need to show
there is possibility of the data to the user which
manipulation on the data. requires no manipulation.
DataSet VS DataReader in ADO.Net
DATASET DATAREADER
• Since DataSet can be serialized • DataReader can’t be serialized
it, can be used in wcf so can’t be used in wcf services
services and web service that and web services.
will return retrieved data.
• But DataReader can only be
• When you need to navigate read once so it can be bound
through the data multiple to a single control and requires
times then DataSet is better data to be retrieved for each
choice e.g. we can fill data in control.
multiple controls

You might also like