Board index » delphi » How to force the completion of a Post event

How to force the completion of a Post event

Using Append ... Post loop with quite a few records, sometimes the
Locate will return false especially on some slower machines.  I am
currently using Applications.ProcessMessages(); and then check Locate,
if false, do a Refresh.  This takes very long time to complete.  Is
there a more delicate way I can force the application to complete the
post event for all the database update, so the Locate will always return
true for just appended records?  Thanks

James

 

Re:How to force the completion of a Post event


Is this on a network?  If so:
Are you sure that machine speed is the problem?
Make sure local share = true in the bde configuration
of every machine

The OS on the posting machine could also be
caching writes to the network drive.

The processmessages loop may cause the
application to possible go in another direction before
redoing the locate.
Wouldn't it be better to put in a timed retry if the
locate is false.  I would try that without the refresh.
All this is assuming Paradox.......... not a client/server setup.

James M. Lucas <JMLu...@LegendNet.com> wrote in message
news:37CE9A06.A4AE72ED@LegendNet.com...

Quote
> Using Append ... Post loop with quite a few records, sometimes the
> Locate will return false especially on some slower machines.  I am
> currently using Applications.ProcessMessages(); and then check Locate,
> if false, do a Refresh.  This takes very long time to complete.  Is
> there a more delicate way I can force the application to complete the
> post event for all the database update, so the Locate will always return
> true for just appended records?  Thanks

> James

Re:How to force the completion of a Post event


It is a standalone program and can be configured to run on a network.  The
backend is Access 97 database.  No cached update is involved.  The strange
thing is: If I dont call a Refresh, sometimes the just appended records do not
show up in DBGrid, Locate will not always return true right after Post(If I
open the very database with another program, the records are there).  If I
call a Refresh, of course, it works, but it becomes really slow.  I could not
do a timed check since I need a field from the new record right away: an
autoinc field which I will use as index for further processing.  Thanks.

James

Quote
Art Begun wrote:
> Is this on a network?  If so:
> Are you sure that machine speed is the problem?
> Make sure local share = true in the bde configuration
> of every machine

> The OS on the posting machine could also be
> caching writes to the network drive.

> The processmessages loop may cause the
> application to possible go in another direction before
> redoing the locate.
> Wouldn't it be better to put in a timed retry if the
> locate is false.  I would try that without the refresh.
> All this is assuming Paradox.......... not a client/server setup.

> James M. Lucas <JMLu...@LegendNet.com> wrote in message
> news:37CE9A06.A4AE72ED@LegendNet.com...
> > Using Append ... Post loop with quite a few records, sometimes the
> > Locate will return false especially on some slower machines.  I am
> > currently using Applications.ProcessMessages(); and then check Locate,
> > if false, do a Refresh.  This takes very long time to complete.  Is
> > there a more delicate way I can force the application to complete the
> > post event for all the database update, so the Locate will always return
> > true for just appended records?  Thanks

> > James

Re:How to force the completion of a Post event


Are you doing the locate in the afterpost event?
Maybe instead try using PostMessage to post a user defined
message that calls a procedure which contains the locate.
That way the afterpost can finish cleanly.  I don't know if that will
help but it might.

James M. Lucas <JMLu...@LegendNet.com> wrote in message
news:37CEEA77.CF6539D6@LegendNet.com...

Quote
> It is a standalone program and can be configured to run on a network.  The
> backend is Access 97 database.  No cached update is involved.  The strange
> thing is: If I dont call a Refresh, sometimes the just appended records do
not
> show up in DBGrid, Locate will not always return true right after Post(If
I
> open the very database with another program, the records are there).  If I
> call a Refresh, of course, it works, but it becomes really slow.  I could
not
> do a timed check since I need a field from the new record right away: an
> autoinc field which I will use as index for further processing.  Thanks.

> James

Re:How to force the completion of a Post event


Thanks for the suggestion, my structure is like this:

A few records:

for i := 0 to count do
begin
Append;
...
Post;
end;

then trying to locate each autoinc id through
for i := 0 to count do
begin
Locate(... );
do something with autoinc id
end;

I will try to find out if I could do something through postmessage way as you
suggested.  I used it before for a single record, but not sure how it holds for
a group of records -- if they will be queued sequentially?  Refresh is a littel
too time consuming even for less than 100 records.

James

Quote
Art Begun wrote:
> Are you doing the locate in the afterpost event?
> Maybe instead try using PostMessage to post a user defined
> message that calls a procedure which contains the locate.
> That way the afterpost can finish cleanly.  I don't know if that will
> help but it might.

> James M. Lucas <JMLu...@LegendNet.com> wrote in message
> news:37CEEA77.CF6539D6@LegendNet.com...
> > It is a standalone program and can be configured to run on a network.  The
> > backend is Access 97 database.  No cached update is involved.  The strange
> > thing is: If I dont call a Refresh, sometimes the just appended records do
> not
> > show up in DBGrid, Locate will not always return true right after Post(If
> I
> > open the very database with another program, the records are there).  If I
> > call a Refresh, of course, it works, but it becomes really slow.  I could
> not
> > do a timed check since I need a field from the new record right away: an
> > autoinc field which I will use as index for further processing.  Thanks.

> > James

Re:How to force the completion of a Post event


If your application is still being designed,
maybe you should dump the autoincrement
and instead store  the next value in another table and increment
the value in the other table after you get it.

Other Threads