ASP.NET data access

D

DwC

Hi,

We have a ms access database that we will be using to develop a website
which would have fairly low usage levels.

We have some experience with windows apps but not so much with asp.net
projects. We have used ADO datasets previously for a windows application
that we developed where the entire db was loaded into the dataset at the
beginning of the application and the user made changes to the dataset
which was then saved back to the db when the app was shut down.

We now have to develop the asp app and we can't quite work out which
technique we should be using:

1 - the original technique which seems like a huge waste of resources
for a web app - loading the data from the db into the dataset each time
the db access class is created. Which means that when data is required
it is returned from the dataset saving a connection, but has used a heap
of resources loading from the db in the first place. This also raises
the question of when to synchronise the dataset and the db.

2 - using datareaders to directly access the data required. When the
page loads it creates a db access class which has a connection and
methods which when called open the connection, pack the data into the
return object (which could be strings, collection, or user defined)
using the datareader and then close the connection and return the packed
object. We would in this case have insert methods which would then use
inserts, updates and deletes to directly update the database.

3 - using datasets from each method in the db access class instead of
one large dataset. So the methods would be like:
private DataSet GetProducts() etc..
instead of one large dataset. We would then have a update or delete
method or whatever which would take back a dataset and make the changes
directly to the database. The problem that this technique seems to have
is that you are creating a dataset in each method, which is failur
repetitive and may only contain a few rows.

If anyone can help by totally ruling out any of these options or
providing different techniques it would be greatly appreciated. I have
done some research about this but haven't been able to find a really
good resource that explains the preferred technique for a web app.

Thanks in advance.
 
G

Guest

Hi DwC,

Since you need disconnected data (DataSet), datareader is not necessary.
It’s better to use dataadapter to fill dataset. And if your individual
Dataset is from single DB table, you don’t have to create your own inserts,
updates and deletes methods. You can use dataadapter (combining with
commandbuilder) to fill dataset. Then you can use dataset.Update method to
update data back to DB (commandbuilder can automatically generate
corresponding update (insert, delete, or update) command(s).

HTH
Elton Wang
(e-mail address removed)
 
S

Sean M

DataReaders are far more performant (mrrr, is that a word?) than
DataSets if all you are doing is _reading_ data from a DB. But if you have
to do any editing you'll probably want to use a DataSet. Just be sure to be
kind to the .NET Framework and call Dispose() on the DataSet object when you
no longer need it (don't just let it fall out of scope).

-- Sean M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top