473,387 Members | 1,624 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,387 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 1255
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, including column names and row values for each column. ...
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 how can I get my base DataSet object assigned an...
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 that does a query and returns a data reader and...
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 tried dataset as a datatype, but I can't get it to...
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 this data and store it in the database. later, then...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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...

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.