Dataset and datatable

Discussion in 'ASP .Net' started by =?Utf-8?B?QWxla3MgS2xleW4=?=, Aug 6, 2007.

  1. 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?
     
    =?Utf-8?B?QWxla3MgS2xleW4=?=, Aug 6, 2007
    #1
    1. Advertising

  2. =?Utf-8?B?QWxla3MgS2xleW4=?=

    sloan Guest

    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".





    "Aleks Kleyn" <> wrote in message
    news:...
    >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?
    >
     
    sloan, Aug 6, 2007
    #2
    1. Advertising

  3. "Aleks Kleyn" <> wrote in message
    news:...

    > 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...?


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Aug 6, 2007
    #3
  4. =?Utf-8?B?QWxla3MgS2xleW4=?=

    Aleks Kleyn Guest

    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.

    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "Aleks Kleyn" <> wrote in message
    > news:...
    >
    >> 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...?
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    Aleks Kleyn, Aug 7, 2007
    #4
  5. "Aleks Kleyn" <> wrote in message
    news:...

    > 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...?


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Aug 7, 2007
    #5
  6. 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.

    "Mark Rae [MVP]" wrote:

    > "Aleks Kleyn" <> wrote in message
    > news:...
    >
    > > 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...?
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    >
    >
     
    =?Utf-8?B?QWxla3MgS2xleW4=?=, Aug 7, 2007
    #6
  7. "Aleks Kleyn" <> wrote in message
    news:...

    > 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...?


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Aug 7, 2007
    #7
  8. =?Utf-8?B?QWxla3MgS2xleW4=?=

    Aleks Kleyn Guest

    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?
    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "Aleks Kleyn" <> wrote tin message
    > news:...
    >
    >> 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...?
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    Aleks Kleyn, Aug 8, 2007
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nedu N
    Replies:
    1
    Views:
    1,839
    Chris Taylor
    Oct 31, 2003
  2. J. Babe
    Replies:
    1
    Views:
    8,428
    Kevin Spencer
    Aug 15, 2003
  3. Nedu N
    Replies:
    2
    Views:
    2,207
  4. Fredrik Rodin

    Sort a datatable and create a new datatable

    Fredrik Rodin, Feb 16, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    9,114
    paul.mariotti
    Sep 28, 2007
  5. Nedu N
    Replies:
    2
    Views:
    242
    Jacob Yang [MSFT]
    Oct 31, 2003
Loading...

Share This Page