473,698 Members | 2,972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1887
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.co m
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.co m
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******** ******@TK2MSFTN GP15.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******** ******@TK2MSFTN GP15.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
3130
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 a DataAdapter to more easily load the DataSet,but that would entail loading a couple of gigs worth of datainto memory at once, which is bound to be bad. So I'm trying touse a DataReader to collect a group of rows, one row at a time,until I have a...
0
230
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 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...
2
1287
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 help me with the syntax please? Thanks in advance for youe answer
2
1245
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 values of columns of returned rows to Labels in the client aplication such as: while (dtrJobDetails.Read()) { l_shortjobdesc.Text = dtrJobDetails.ToString();
14
2237
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 should be up to date. However, both the IbuySpy and Duwamish samples and most, if not all, the shopping cart sample codes I've seen use dataset to implement the opration for ecommerce sites. So is the trip that the datareader need to go fetch the...
2
1730
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 data to other pages that would call it. I'd return the data as arrays so that I wouldn't have to have my DB connections open all the time while the pages ran. Now in .net, it seems like I have to choose between using a SQldatareader or a...
1
1665
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 to work on. I know that the DataReader is more efficient and faster than a dataset, but I was not able to figure out how to implement it. Here is the code I have now which works: Private Sub frmProjects_Load(ByVal sender As System.Object,...
4
1927
by: Mike | last post by:
Hello, How can I get Random data from Dataset or datareader THanks -- Regads, Rochdi
7
3797
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 the changed? I'm using VS2005 with .net 3.0.
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8611
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
5867
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.