472,333 Members | 1,024 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

DataSet vs. SQL

I'd like to know when a DataSet is the preferred way to retrieve, and
specifically update/delete, data in an ASP.NET application. I've been using
straight SQL by using the SqlCommand and SqlDataReader objects. I'd like to
know if there is anything wrong with this approach. It appears that if you
want to use a DataSet for an update that you have to persist it so you can
use it in a subsequent postback. That seems like it might become expensive,
but maybe the cost of persisting it is outweighed by some other optimization
that I am not aware of. Any help would be much appreciated.

Thanks.
Nov 19 '05 #1
2 1214
SqlDataReader will be slightly faster than the DataSet when just using them
for data binding, primarily because the DataSet is an extra in-memory copy
of the data. So if your situation is just data binding, then go for the data
reader approach. But this also means you're always going to the data base
for the data. If you're looking to hold onto the data for a longer period
(for caching purposes or for doing extra processing on the data) then that's
when you'd prefer a DataSet. The DataSet also allows you to create additional
columns that are calculated and in conjunction with the DataView you can
easily get sorting and filtering (not that you can't with SQL statements
back in the DB, but the work's offloaded to the webserver).

Anyway, the fact that you're simply aware of the two is a good start. Each
one has its place.

-Brock
DevelopMentor
http://staff.develop.com/ballen
I'd like to know when a DataSet is the preferred way to retrieve, and
specifically update/delete, data in an ASP.NET application. I've been
using straight SQL by using the SqlCommand and SqlDataReader objects.
I'd like to know if there is anything wrong with this approach. It
appears that if you want to use a DataSet for an update that you have
to persist it so you can use it in a subsequent postback. That seems
like it might become expensive, but maybe the cost of persisting it is
outweighed by some other optimization that I am not aware of. Any
help would be much appreciated.

Thanks.


Nov 19 '05 #2
Hi epigram,
I'd like to know when a DataSet is the preferred way to retrieve, and
specifically update/delete, data in an ASP.NET application.
The first scenario that comes to mind is when you SELECT a group of records,
allow the client to edit multiple records, and then do an UPDATE of all the
edited records in one swell foop.

You are wise to want to eliminate unnecessary overhead in your app. If
you're updating a single Record, the method you've described is going to be
faster and more efficient. Just be aware that the more responsibility you
take for yourself by going to a lower level (a DataSet is populated by a
DataReader internally), you will have to accept that responsiblity and
handle it well, such as making sure that the DataReader and Connection are
closed in your code.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"epigram" <no****@spammy.com> wrote in message
news:1114513511.e4292df6a5fd5c9974b04a38277393cd@b ubbanews... I'd like to know when a DataSet is the preferred way to retrieve, and
specifically update/delete, data in an ASP.NET application. I've been
using straight SQL by using the SqlCommand and SqlDataReader objects. I'd
like to know if there is anything wrong with this approach. It appears
that if you want to use a DataSet for an update that you have to persist
it so you can use it in a subsequent postback. That seems like it might
become expensive, but maybe the cost of persisting it is outweighed by
some other optimization that I am not aware of. Any help would be much
appreciated.

Thanks.

Nov 19 '05 #3

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

Similar topics

3
by: Bill C. | last post by:
Hi, I've got a simple console app that just reads an XML file into a DataSet then prints out a description of each table in the DataSet,...
5
by: Mike | last post by:
I need to expand the DataSet class by inheriting from it and adding functions that work on the data in the tables. However, since I can't upcast...
2
by: John Holmes | last post by:
I have a web interface where the user types in ID's one at a time. After an ID is typed in, a button is clicked and the button click event has code...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have...
1
by: matt | last post by:
hello, i have a web app that allows users to query our oracle db and produce a dataset of report data. they then have the option to serialize...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.