Re: Displaying datatable in datagrid while table's being filled...

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: VM (vonchi_m_at_yahoo.com)
Date: 05/27/04


Date: Thu, 27 May 2004 13:00:37 -0400

Thanks for your reply.
The process takes so long because I'm querying their own proprietary "DB"
through their API. Since the API only returns one record at a time, I
manually fill up the table with data by appending each additional row I
receive. Then I return it to the UI.
I was thinking of getting small chunks of the data at once like you
suggested, but I'm not sure how to do it. In the UI, the OK event handler
has two instructions:

_dataTableBrowse = ZMDataBrowse.ZM_getAddressDataSet(additional parms);
//this is what takes so long because it's filling the table
dataGrid_browse.DataSource = _dataTableBrowse;

Thanks.

"William Ryan eMVP" <dotnetguru@comcast.nospam.net> wrote in message
news:uIlbBeAREHA.3608@TK2MSFTNGP10.phx.gbl...
> I'd spin it off into another thread (which is a good idea for all db
access
> if you are doing it in the same thread as the UI), put up a wait box of
some
> sort and go from there. You can break it into smaller queries but that's
> going to slow the process overall in many instances, then again, there are
a
> lot of possible variables.
> 1) Is the query taking forever b/c it's huge (ie 10000 records) or is it
b/c
> it just takes a long time on the server? It it's b/c it's 10000 records,
> then you may benefit from breaking it up
> 2) The user many not need all of that data since the grid only displays
> less than 50 records at a time in most UI Scenarios. You may want to wait
> for the user to scrolll down or something before getting the additional
data
> 3) You should bind the grid to the table only once. If you clear it, then
> it will appear to clear itself.If you fill it it will automatically show
the
> data.. In doing so you could keep filling the table with additional
queries
> However you are either going to freeze the ui or you'll need to synclock
the
> grid (you don't want multiple threads accessing the datatable without
> locking it) it which will impede the effect you want.
> 4) What in the world is causing a query that long? That's the biggest
> problem. If it's sheer number of records, then you are without a doubt
> dealing with more data than the user is going to need at once. If you
want
> to pull 10000 records or slow, you can't expect to have a speed demon
> (nothing magic about 10,000, my point is merely really large record
counts.)
> If the querry is taking that long to process on the server, you'll want to
> figure out why and address this. Unless it's serious batch processing or
> something, that's a LONG time for a query to run considering most take
about
> a second at most. I'd tune this up and get it running as fast as
possible.
>
> Even if you did 500 at a time, assuming that the size is the problem, you
> could show the 500, then, if the user scrolls to a point that you need
more
> or hits a navigate button indicating more are needed, you could throw up a
> wait box, grab another 500 (calling Datadapter.Fill(datatable) without
clear
> will append the records to the end which is what you want). Since you
have
> much smaller records this should be fast and a wait box should be
tolerable.
> You can do this until the table is filled.
>
> The point if it's huge is that it's doubtful the user is going to use 10k
> records in one immediate sitting. The phone might ring, a meeting may come
> up or whatever. So anything more than he needed is wasted.
>
> I think if you use threading correctly you can make the UI much more
> responsive and they can do something else while the grid is filling. And
if
> you don't rebind it each time, just call .Fill on the table that the grid
is
> already bound to, you should be able to make this manageable.
>
> HTH,
>
> Bill
>
> --
>
> W.G. Ryan, eMVP
>
> http://forums.devbuzz.com/
> http://www.knowdotnet.com/williamryan.html
> http://www.msmvps.com/WilliamRyan/
> http://www.devbuzz.com/content/zinc_personal_media_center_pg1.asp
> "VM" <vonchi_m@yahoo.com> wrote in message
> news:%23q0FxMAREHA.3660@tk2msftngp13.phx.gbl...
> > When I display data to a Windows datagrid I usually fill the underlying
> > table (in another class) and then, once it contains all the data, I
attach
> > it to the grid. But there are some processes that involve large amounts
of
> > data so the user won't be able to see anything in the grid until after
the
> > table's already filled up (usually 40-60 secs with these large
processes).
> > Is it possible (without changing the process of filling the table
> elsewhere)
> > to display some data in the grid while the table's filling up? I was
> > thinking of displaying X records every few seconds. That way the user
has
> > something to look at.
> >
> > thanks.
> >
> >
>
>



Relevant Pages

  • Re: Limit of Binary Lists
    ... we were filling in agrid. ... "The Cantor set itself is of course a Cantor space. ... that is a sequence which assumes only the values 0 or 1." ...
    (sci.math)
  • Re: Displaying datatable in datagrid while tables being filled...
    ... Is the query taking forever b/c it's huge or is it b/c ... You should bind the grid to the table only once. ... In doing so you could keep filling the table with additional queries ... > When I display data to a Windows datagrid I usually fill the underlying ...
    (microsoft.public.dotnet.languages.csharp)