473,387 Members | 1,890 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.

SqlDataReader question

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
Nov 18 '05 #1
4 1389
Griff,

SqlDataReader is fast but is limited; it cannot do disconnected but it is
also forward only, and you will be stuck with writing concurrency mgmt from
the very scratch. Is it faster? In a single user scenario yes, in a multiple
user scenario, when database connections could be pooled, the difference
reduces.

SqlDataSet ---> There is nothing like that. DataSet is always common between
various d/bs.

WebService communication resort to XML ---> WebServices use SOAP, which are
XML. Does this mean you have to pass XML back and forth as data types from
WebMethods? Not really. Does this mean you should pass data as XML as
return/accept parameters from webservices -- Nope.

DataSets are the preferred solution for getting the data out of the d/b,
working in a disconnected mode, and persisting changes back.

- Sahil Malik
You can reach me thru my blog at
http://www.dotnetjunkies.com/weblog/sahilmalik
"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

Nov 18 '05 #2
I think you may have misunderstood the article. If a DataReader was always
the best choice, there would not be a DataSet or DataTable class. These are
3 distinctly different kinds of tools, and each is best suited for the
purposes for which it was implemented.

That said, the DataReader has the least amount of overhead, and is faster.
It also has some issues which DataSet and DataTable do not, such as being
read-only, forward-only, and necessitating that a Connection remain opened
dring its entire lifetime. DataSets and DataTables are disconnected Record
Sets. The DataSet is also implicitly serializable as XML.
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?
Web Services are all about XML under the hood. However, they are not all
about DataSets. Web Services are simply a mechanism for making method calls,
and passing objects back and forth across a Network. So, again, there is no
"preferred solution." If you think of yourself as a builder, and these
classes and technology as tools, you should be able to see that no tool is
inherently better than any other tool, except in the context of what you're
building with it.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"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

Nov 18 '05 #3
Think of a DataSet/DataTable as a disconnected, client-side cache that
holds data *after* it has been fetched from the data source. The
DataSet has no knowledge of or connection to the data source
whatsoever. DataReaders and DataAdapters are what connect to the data
source, not DataSets, so DataSets are always disconnected. It's not a
question of using one over the other--you need both,
DataReaders/DataAdapters to interact with the database, and DataSets
to provide a local disconnected cache. I have never heard of a
SqlDataSet--where did you get that from? See the topic in the Help
file, "XML and the DataSet"
ms-help://MS.VSCC.2003/MS.MSDNQTR.2004APR.1033/cpguide/html/cpconXMLDataSet.htm
for more information on how to work with XML/Datasets.

HTH,

Mary

On Fri, 15 Oct 2004 15:17:44 +0100, "Griff" <Ho*****@The.Moon> wrote:
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


Nov 18 '05 #4
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

Nov 18 '05 #5

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

Similar topics

2
by: Rod | last post by:
Thanks in advance. I have two listboxes on a single asp page. I am trying to use sqldatareader to populate both using two seperate sql stored procs. I can populate each box seperately using...
3
by: Ricola ! | last post by:
Why do I say: SqlDataReader dr; instead of SqlDataReader dr = new SqlDataReader();
3
by: PeteZ | last post by:
I'm having a problem where I exec a stored procedure (which SELECTs all rows from a table, which has 100 rows) - each row has 8 columns. When I exec the code (see below) I get 8 in...
7
by: Franck Diastein | last post by:
Hi, when I call ExportData I have this error: Invalid attempt to Read when reader is closed. Telling me that there's a problem with this line: while(_dataR.Read()){ Code:...
3
by: Neil Guyette | last post by:
Hello, Everyone, I'm trying to find information on how to populate a combo box using a SqlDataReader. I want to be able to set the value of the combo's value property different then the...
5
by: Wing | last post by:
Hi all, I execute a stored procedure in my C# code, assign the result to the SqlDataReader object and display it with datagrid. the question I like to ask, is possible to edit the datagrid...
1
by: Arvind P Rangan | last post by:
Hi All, How do you get all the values of a sqldatareader if it contains multiple resultset. Using sqldatareader.nextresult and sqldatareader.read e.g. While sqldatareader.read ' If not...
4
by: mimi | last post by:
Hi Please help me out, I can't find a way to close a sqldatareader when error occur at statement cmd.ExecuteReader(). I can't close it in catch because it is local in try scope and I can't...
2
by: SQL | last post by:
I'm new at this, so please forgive me if my question has a simple answer to it. I'm trying to get a value out of a SqlDataReader. Here is my code to do so: Dim mySQLCommand As New...
3
by: Frank Milverckowitz | last post by:
Hi, Newbie question about SqlDataReader column value access... In java jdbc code to get a value from a table column we can pass the column name (instead of an int index or offset): String...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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.