Preferred is a big word but overall, in many distributed system, DataSets
have more applicability. You can't serialize a DataReader so it's only
useful within the context of an open and available database connection. As
such you can't remote it, return it from a web service etc. A dataset can
use a DB COnnection but it doesn't have to. Obviously to interact with a
database it needs one but it doesn't have to have one to be useful.
(Incidentally, if you look at just about any exception message that you get
from the db, you'll notice in the stack trace that a data reader is
mentioned. This is because, under the covers, readers are used to
facilitate just about anything you do with the db - they are even used when
you fill a dataset with a DataAdapter.)
In the context of Enterprise solutions though, it's often useful to think in
terms of SOA. What service are you going to provide? You can have for
instance a facade that gets called from the client. The facade in turn
invokes some method to get the data it needs and it returns it. By doing
things this was, you can change your back end around quite a bit and the
client would never know the difference. SOA in turn allows you to use a
DataReader, MSMQ, Web Service or whatever else to get the client the data
you need so it affords quite a bit of flexibility
Take a look at the Microsoft Data Access Application Block - and some of the
examples there, it should be a good starting point in helping you to
understand how to use each.
--
W.G. Ryan, MVP
www.tibasolutions.com |
www.devbuzz.com |
www.knowdotnet.com
"Griff" <Ho*****@The.Moon> wrote in message
news:O6****************@TK2MSFTNGP09.phx.gbl...
The MSDN article:
Developing high-performance ASP.NET applications
recommends using the SqlDataReader above using DataSets.
One of the advantage of using DataSets over DataReaders is (as I
understand it) that DataSets are preferred for n-tier architecture because they can
be disconnected from the database.
I can't find any information on whether the SqlDataSet can also be
disconnected. I assume that they can, but can someone confirm that for
me.
Also (I've not read up on it yet), but I assume that if some of the tiers
communicate via web-services then one has to resort to XML? If so, are
DataSets the preferred solution then?
Many thanks
Griff