Dataset and datatable

G

Guest

I use in my asp.net code dataset and populate datatable using dataadapter.

The problem is that my code demand huge amount of memory and I am looking
for way reduce this demand.

At this time I keep links to dataset, dataadapter and datatable in session.

As I understand datatable is class and specific datatable does not belong
directly to dataset and using the same dataadapter I can populate two
datatables different way from the same real table. Does it mean that if I
move dataset to application level and limit scope of dataadapter and
datatable to specific page I will save in memory. Or better to keep dataset
on level of session collection?
 
S

sloan

DataSets are very "cure all" objects. They allow binding (for one thing) in
a winforms application, and thus have some overhead as far as implementing
the IEditableObject interface.

So you're saying "why is he telling me about a winforms app? I'm in the
asp.net newsgroup".

Because you pay that price for using a DataSet (or strongly typed dataset).
Even in an asp.net application.


You can do a google search for
IDataReader DataSet
and you'll find some references about that.


You have to ask yourself a few question. Do I need the entire collections
of objects in memory for anything?
Am I just binding data to some output (repeater, gridview, etc)?

Here is one option for reducing overhead.
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!140.entry

Use an IDataReader to put your data_values into objects, and then those
objects into collections.


You can also (usually) bind a repeater control (one example that is) to an
IDataReader, although personally I don't like having IDataReaders floating
around in the presentation layer.

It this a "quickie application"? Or something that's going to be around for
a while.

Keep in mind, that Rapid Development doesn't always mean (or perhaps seldom
means) ... "good development".
 
M

Mark Rae [MVP]

At this time I keep links to dataset, dataadapter and datatable in
session.

Why?

Unless the data is relatively small, and needs to be fetched *once only* per
session (e.g. maybe some metadata about the currently logged-on user), it is
(nearly) always preferable to fetch data as and when it's needed.

As a general rule, the more "room" you can give your ASP.NET app, the better
it will perform. ADO.NET uses something called connection pooling which
means that many small database reads will always perform much better then a
few large database reads.

Overuse of session is one sure way of cripping your ASP.NET app - how much
data are you actually storing in session...?
 
A

Aleks Kleyn

This is asp.net application. For instance. I read large amount of data to
present in datagrid. I cannot show all data on the same page, it will take a
work to scroll down a screen. I prefered datatable because it is ready
collection, I have read data from database and connection is closed. However
when I call on datagrid next page I reload page. So I have choice. I
populate datatable one time more. Or I save it in session collection.
However I discovered, when I choose second choice and 10-15 people use this
web page, the amount of memory for aspnet.exe grows 2kb each 5-10 sec. This
continues until 100% cpu time is dedicated to memory paging. This clearly
means that I need to find better answer.
 
M

Mark Rae [MVP]

This is asp.net application. For instance. I read large amount of data to
present in datagrid. I cannot show all data on the same page, it will take
a
work to scroll down a screen. I prefered datatable because it is ready
collection, I have read data from database and connection is closed.
However
when I call on datagrid next page I reload page. So I have choice. I
populate datatable one time more. Or I save it in session collection.
However I discovered, when I choose second choice and 10-15 people use
this
web page, the amount of memory for aspnet.exe grows 2kb each 5-10 sec.
This
continues until 100% cpu time is dedicated to memory paging. This clearly
means that I need to find better answer.

Correct, and the better answer is not to persist the data in session.

Also, is there any reason that you're using DataGrid instead of GridView...?
Are you still using ASP.NET v1.1...?
 
G

Guest

No, it is gridview. But it is hard to keep all names in memory and I
sometimes use old names. I do not think it is possible to use dataset in asp
1.0. I understand your point. However one question more. Suppose I expect to
use data from selected row. During the time when user loaded page and clicked
link on it the other user was able to add new records. This means that to
find selected record is better bind dataview to collection.
 
M

Mark Rae [MVP]

No, it is gridview. But it is hard to keep all names in memory and I
sometimes use old names.

I can understand that. However, it's worth trying to use the correct
terminology when posting here because it really helps people to find a
solution for you...
I do not think it is possible to use dataset in asp 1.0.

It was / is. DataSets and DataReaders have existed since the very first
release.
However one question more. Suppose I expect to
use data from selected row. During the time when user loaded page and
clicked
link on it the other user was able to add new records. This means that to
find selected record is better bind dataview to collection.

I apologise, but I don't know what you mean - can you please explain a bit
further...?
 
A

Aleks Kleyn

In the most cases user reads information from the screen or using links he
can go to other page. At time of databinding I can put into link valuable
data, so next page knows what to do. However gridview has oportunity to use
edit or delete buttons. I need to provide code for appropriate events. I did
not see oportunity to get data from selected row. After some research I
found that I can get row and page number and these values together give me
ability to find in binding collection appropriate data.
If bind directly to database then next time I need to use the same query,
but it cannot waranty that information did not change. In this case I need
to bind to collection. Probably this collection should be saved in session,
I do not see other solution. Or is better to create my own link?
 

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,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top