473,412 Members | 4,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

novice: dataset and datareader

hi , i have been looking around on msdn and google but i still have a couple
of oquestions about the difference between a datareader and a dataset -
which to use when -
1) do i have to choose between one fo the 2 in my page ?
2) i am creating a " forgot my password" page- and i want to execute a query
based on the email address entered in my form - what do i with the result -
use datareader to get the password and send by email or use the dataadapter
+ dataset to get the password /
3) also i rad that the after you create a dataset then you are able to bind
page controls to the data ?thx in advance
Nov 16 '05 #1
6 1858
Nabil,

A DataReader is a class that provides forward only access to your data.
This means that if you perform a query, then you access the rows in the
query one by one, and you can not update it.

A DataAdatper takes four queries (select, insert, update, delete) and
will populate a data set based on the select query. Once you make changes
to the data set, you can pass the data set back to the data adapter, and
based on the state of the rows (changed, deleted, inserted), it will perform
the appropriate queries.

A DataAdapter actually uses a DataReader under the covers to populate
the data set.

Now when choosing between the two, you have to consider a few things.
It appears you are in an ASP.NET page, so you can actually bind controls to
either a DataReader or a DataSet. If the list that you are binding to is
not volatile (the data is pretty much the same every time you populate the
list), then I would use a data set to bind to the list. The reason for this
is that you will take the hit once for populating the data set, but on
subsequent data binds, you can retrieve the data set from the Session, or
the Cache. Subsequent binds would be much, much faster.

Also, if you want to update the data back on the database (it changes
somehow), then I would recommend a data set.

Typically, for data binding situations, I say go with the data set
(especially in windows forms applications). In ASP.NET, I would be a little
more leinient, and say that if your data is volatile (changing all the
time), then use the data reader and bind to the list to that.

In situations where you just want to process the results (like for a
report), I would say go with a data reader.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
Nov 16 '05 #2
Nabil,

A DataReader is a class that provides forward only access to your data.
This means that if you perform a query, then you access the rows in the
query one by one, and you can not update it.

A DataAdatper takes four queries (select, insert, update, delete) and
will populate a data set based on the select query. Once you make changes
to the data set, you can pass the data set back to the data adapter, and
based on the state of the rows (changed, deleted, inserted), it will perform
the appropriate queries.

A DataAdapter actually uses a DataReader under the covers to populate
the data set.

Now when choosing between the two, you have to consider a few things.
It appears you are in an ASP.NET page, so you can actually bind controls to
either a DataReader or a DataSet. If the list that you are binding to is
not volatile (the data is pretty much the same every time you populate the
list), then I would use a data set to bind to the list. The reason for this
is that you will take the hit once for populating the data set, but on
subsequent data binds, you can retrieve the data set from the Session, or
the Cache. Subsequent binds would be much, much faster.

Also, if you want to update the data back on the database (it changes
somehow), then I would recommend a data set.

Typically, for data binding situations, I say go with the data set
(especially in windows forms applications). In ASP.NET, I would be a little
more leinient, and say that if your data is volatile (changing all the
time), then use the data reader and bind to the list to that.

In situations where you just want to process the results (like for a
report), I would say go with a data reader.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
Nov 16 '05 #3
nabil m wrote:
hi , i have been looking around on msdn and google but i still have a
couple of oquestions about the difference between a datareader and a
dataset - which to use when -
1) do i have to choose between one fo the 2 in my page ?
No, you can use both.
2) i am creating a " forgot my password" page- and i want to execute
a query based on the email address entered in my form - what do i
with the result - use datareader to get the password and send by
email or use the dataadapter + dataset to get the password /
For such straightforward queries, I'd use an IDbCommand and a DataReader.
3) also i rad that the after you create a dataset then you are able
to bind page controls to the data ?thx in advance


Yes, you can. See the numerous samples on MSDN on server controls and data
binding.

Cheers,

--
Joerg Jooss
jo*********@gmx.net
Nov 16 '05 #4
nabil m wrote:
hi , i have been looking around on msdn and google but i still have a
couple of oquestions about the difference between a datareader and a
dataset - which to use when -
1) do i have to choose between one fo the 2 in my page ?
No, you can use both.
2) i am creating a " forgot my password" page- and i want to execute
a query based on the email address entered in my form - what do i
with the result - use datareader to get the password and send by
email or use the dataadapter + dataset to get the password /
For such straightforward queries, I'd use an IDbCommand and a DataReader.
3) also i rad that the after you create a dataset then you are able
to bind page controls to the data ?thx in advance


Yes, you can. See the numerous samples on MSDN on server controls and data
binding.

Cheers,

--
Joerg Jooss
jo*********@gmx.net
Nov 16 '05 #5
thank you guys!

"nabil m" <na***@hagedorn.com> wrote in message
news:es**************@TK2MSFTNGP15.phx.gbl...
hi , i have been looking around on msdn and google but i still have a
couple of oquestions about the difference between a datareader and a
dataset - which to use when -
1) do i have to choose between one fo the 2 in my page ?
2) i am creating a " forgot my password" page- and i want to execute a
query based on the email address entered in my form - what do i with the
result - use datareader to get the password and send by email or use the
dataadapter + dataset to get the password /
3) also i rad that the after you create a dataset then you are able to
bind page controls to the data ?thx in advance

Nov 16 '05 #6
thank you guys!

"nabil m" <na***@hagedorn.com> wrote in message
news:es**************@TK2MSFTNGP15.phx.gbl...
hi , i have been looking around on msdn and google but i still have a
couple of oquestions about the difference between a datareader and a
dataset - which to use when -
1) do i have to choose between one fo the 2 in my page ?
2) i am creating a " forgot my password" page- and i want to execute a
query based on the email address entered in my form - what do i with the
result - use datareader to get the password and send by email or use the
dataadapter + dataset to get the password /
3) also i rad that the after you create a dataset then you are able to
bind page controls to the data ?thx in advance

Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rob via .NET 247 | last post by:
Ok, I'm new to .NET so I'm afraid I'm doing something stupidhere, but I'm trying to populate a DataSet manually from aDataReader, and its turning out to be ridiculously difficult. Yes, I could use...
0
by: nabil m | last post by:
hi , i have been looking around on msdn and google but i still have a couple of oquestions about the difference between a datareader and a dataset - which to use when - 1) do i have to choose...
2
by: sean | last post by:
Hi, I am filling a datagrid and I was wondering how I can test for "end of file" and then make decisions based on that. I am still making the transition from asp to asp.net. Could someone...
2
by: Sumaira Ahmad | last post by:
Hi All My Web Service is returning a DataSet. I realized that we cannot return a DataReader.. Normally we can use a DataReader( when not using Web services) and access it as below to assign...
14
by: Bihn | last post by:
I was reading about datareader which is said to be slimmer & faster then dataset. Since the datareader have to go fetching the dat from the database every time it need it, the data it gets then...
2
by: Patreek | last post by:
Hi, I'm writing my first real asp.net app at my job, and I'd like opinions please. In my classic ASP apps that I've written, I'd often have separate files for retreiving data and returning the...
1
by: Ivan Weiss | last post by:
Hey all, I have the following code to populate a ListView control from my Access database. The listview is displaying a list of saved projects that the user will be able to open, edit, or delete...
4
by: Mike | last post by:
Hello, How can I get Random data from Dataset or datareader THanks -- Regads, Rochdi
7
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I have read some articles state that DataSet should NOT be used for large resultset. What does "large" mean? Is "large" based on # of rows/columns and/or memory required to hold the original and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.