ADO.NET Objects to Use

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

ADO.NET seems to provide a million objects for accessing data and I'm a little confused.

First, let me describe how the data is accessed on my site:

- ALL data is accessed through calls to stored procedures which may or may not change data in the database but which ALWAYS return data (sometimes multiple rows, sometimes only 1).

- I NEVER return more than one table of data from any database call.

- I NEVER edit data in the database by changing the result set returned from a previous call. In other words, if changes are made to the database, it's ALWAYS through calls to new stored procedures and not by the "disconnected data" business.

So, in the end, I only use data which comes back from the database in one of three ways:

1. I programmatically access the data returned and make decisions based on it.
2. I use DataGrids and other nice tools for display-only data-binding (no pagination either).
3. I store tables of data returned from the database in the Application Object for repeated binding to things like pull-down controls, etc.

I'm looking for the most efficient and resource-sensitive objects to use for each of these functions above (1, 2, and 3) and I'm confused.

Do I use the DataTable object for all of them? It seems like a nice, simple structure that is disconnected from the database after data is returned. I can also store it and use it over and over again to bind to pull-down controls, etc. I read that the DataReader was the most efficient, but you don't seem to be able to re-use the data in it once the DataReader is "Closed."

Your guidance is appreciated.

Alex
 
Hello,

why don`t you just write a real businesslayer, with
objects containing properties (you fill them using a
datareader in a load method). and in case you got plural
objects using a typesafecollection?

otherwise i personally usually just return DataViews in
case i need sorting/filtering on client side.

if you are looking for a time-saving method, maybe check
out microsofts (unsupported) OlyMars, which is generating
your dataaccess (only based on sql-server) and even is
able to create asp.net and winform controls (based upon
your db)

regards

tom


-----Original Message-----
ADO.NET seems to provide a million objects for accessing
data and I'm a little confused.
First, let me describe how the data is accessed on my site:

- ALL data is accessed through calls to stored
procedures which may or may not change data in the
database but which ALWAYS return data (sometimes multiple
rows, sometimes only 1).
- I NEVER return more than one table of data from any database call.

- I NEVER edit data in the database by changing the
result set returned from a previous call. In other words,
if changes are made to the database, it's ALWAYS through
calls to new stored procedures and not by
the "disconnected data" business.
So, in the end, I only use data which comes back from
the database in one of three ways:
1. I programmatically access the data returned and make decisions based on it.
2. I use DataGrids and other nice tools for display-only
data-binding (no pagination either).
3. I store tables of data returned from the database in
the Application Object for repeated binding to things
like pull-down controls, etc.
I'm looking for the most efficient and resource-
sensitive objects to use for each of these functions
above (1, 2, and 3) and I'm confused.
Do I use the DataTable object for all of them? It seems
like a nice, simple structure that is disconnected from
the database after data is returned. I can also store it
and use it over and over again to bind to pull-down
controls, etc. I read that the DataReader was the most
efficient, but you don't seem to be able to re-use the
data in it once the DataReader is "Closed."
 
Your design sounds very typical. Your questions are too--everyone asks them.
Yes, the DataReader is efficient--it's the low-level protocol that simply
streams the data from the server. The Fill method is far more productive and
not that inefficient--especially doing what you're doing. I would stick with
the DataSet/DataTable approach.

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Alex Maghen said:
ADO.NET seems to provide a million objects for accessing data and I'm a little confused.

First, let me describe how the data is accessed on my site:

- ALL data is accessed through calls to stored procedures which may or may
not change data in the database but which ALWAYS return data (sometimes
multiple rows, sometimes only 1).
- I NEVER return more than one table of data from any database call.

- I NEVER edit data in the database by changing the result set returned
from a previous call. In other words, if changes are made to the database,
it's ALWAYS through calls to new stored procedures and not by the
"disconnected data" business.
So, in the end, I only use data which comes back from the database in one of three ways:

1. I programmatically access the data returned and make decisions based on it.
2. I use DataGrids and other nice tools for display-only data-binding (no pagination either).
3. I store tables of data returned from the database in the Application
Object for repeated binding to things like pull-down controls, etc.
I'm looking for the most efficient and resource-sensitive objects to use
for each of these functions above (1, 2, and 3) and I'm confused.
Do I use the DataTable object for all of them? It seems like a nice,
simple structure that is disconnected from the database after data is
returned. I can also store it and use it over and over again to bind to
pull-down controls, etc. I read that the DataReader was the most efficient,
but you don't seem to be able to re-use the data in it once the DataReader
is "Closed."
 
Thanks for Bill's quick response!

Hi Alex,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to know how to return data
from the database and display them in some nice tools using ADO.NET. If
there is any misunderstanding, please feel free to let me know.

In ADO.NET, there are two kinds of scenarios, connected and disconnected.
In a connected scenario, we use a DataReader to get data. The DataReader
object provides a means of reading a forward-only stream of rows from the
database. It requires an open connection to perform the task, so while the
DataReader is in use, the associated connection is busy serving the
DataReader, and no other operations can be performed on the connection
other than closing it. The DataReader is fast in a readonly and
forward-only scenario.

In the disconnected case, we use a DataAdapter to fill an DataSet object. A
DataSet object contains several DataTables and DataRelations between them.
It is a dump of data on the client side. You can bind the DataGrid to the
DataSet object for a nice display and make changes on it. When finished,
you can update the data in database with DataAdapter.Update() method. The
DataSet is much more flexible and requires less resource on the server.
However we need more resource on the client with it.

For more information about ADO.NET object, please check the following link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconoverviewofadonet.asp

HTH. If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Alex,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top