Discussion:
quick sort and refresh
(too old to reply)
M
2006-02-10 20:10:21 UTC
Permalink
I'm developing a program for the maintenance of our internal movie catalogue. It's mainly based
around a list of all product (as opposed to searching) so that people can easily see if they're
entering in a duplicate product. It's mostly used for data entry rather than lookup. At the moment
I'm using IBX and Firebird in BCB6.

I have a grid connected to a TIBDataSet that selects all the items from the database. To edit an
item I get the PK from the selected field on the grid and pass it to the constructor of another form
which then selects all the information for the product. I use a TIBDataSet on the edit form (which
is also used for adding) so it's easy enough to us InsertSQL, DeleteSQL etc. When returning to the
product list refreshing only takes a moment because it's only refreshing the one record.

When adding I do basically the same thing except I pass -1 to the constructor of the add form so it
knows to insert. A problem arises when the add screen closes because I need to refresh the product
list to show the newly added item, except that it involves closing and reopening the dataset and the
select query takes ~7 seconds to open, which when you're adding a few hundred products in one go is
too slow.

I also need to be able to sort the product list when a column title of the grid is clicked which
again is pretty slow because I have to close the dataset, change the ORDER BY clause and then open
it again, taking another ~7 seconds. But that is not so much of a hassle as refreshing.

I know ZeosLib has an internal sort to sort the result set rather than modifying the select query
which works nice and fast, so I tried using a TZDataSet for the product listing but I have to keep
using a TIBDataSet on the add/edit form because I need to use multiple transactions which ZeosLib
doesn't have. That doesn't solve the refreshing problem though.

To speed up refreshing I thought I would try using a TClientDataSet (my first time) which when I
tried it refreshed almost instantly. The problem with that is that I'm still using a TIBDataSet on
the add/edit form so the TClientDataSet doesn't get the changes until I close it and the query it's
attached to and reopen them, which takes another ~7 seconds.

So I suppose what I'm asking is if anyone knows a way of (1) reducing subsequent refreshes of the
dataset (an initial pause while opening for the first time is ok) which would then most probably
solve (2) quickly sorting the dataset without the need to modify the ORDER BY clause and reopen the
query.

TIA
Mark
JD
2006-02-12 03:58:13 UTC
Permalink
M <***@site.com> wrote:
Please reduce the word wrap for you reader by a few characters.
[...] So I suppose what I'm asking is if anyone knows a way
of (1) reducing subsequent refreshes of the dataset
Don't rely on the refresh of the TDataSet. IOW, use a local
copy and insert the new record or change the existing one once
you have updated the db.
(2) quickly sorting the dataset without the need to modify
the ORDER BY clause and reopen the query.
The speed of working with a local copy of the DataSet can't be
beat.

~ JD
M
2006-02-12 20:39:20 UTC
Permalink
Post by JD
Don't rely on the refresh of the TDataSet. IOW, use a local
copy and insert the new record or change the existing one once
you have updated the db.
Have you got a small example?

Thanks

Loading...