Board index » delphi » Problems with Delete 2nd post

Problems with Delete 2nd post

Can someone take a look at this code and see if  there are any glaring
errors.  The problem I'm having is when I go to delete a record immediately
after deleting one I get the message 'Record/Key Deleted'.  Then if I try
again it will delete the record for me without an error, but if I try to
delete again it gives me the error again.  I have CachedUpdates set to true
on this table object:

if MessageDlg('Delete Current Record, Are you sure?',
           mtConfirmation,[mbYes,MbNo],0) = mrYes then
       try
           tblOmsizo.delete;
           tblOmsizo.ApplyUpdates;
      except
           tblOmsizo.CancelUpdates;
           raise;
       end;//Delete

I am using Personal Oracle7 as the DB.

TIA

--
Michael Glatz
mgl...@briefcase.com

 

Re:Problems with Delete 2nd post


Quote
>if MessageDlg('Delete Current Record, Are you sure?',
>           mtConfirmation,[mbYes,MbNo],0) = mrYes then
>       try
>           tblOmsizo.delete;
>           tblOmsizo.ApplyUpdates;
>      except
>           tblOmsizo.CancelUpdates;
>           raise;
>       end;//Delete

You need to call CommitUpdates after successfully applying.

Re:Problems with Delete 2nd post


Quote
>> The problem I'm having is when I go to delete a record immediately
>>after deleting one I get the message 'Record/Key Deleted'.  Then if I try
>>again it will delete the record for me without an error, but if I try to
>>delete again it gives me the error again.  I have CachedUpdates set to true
>>on this table object:

Hmmm... I'm not using TTables for editing in SQL Server apps -  I only use TQuery.

However, you might try calling TTable.Refresh after the delete has been applied.

=Bill=

Re:Problems with Delete 2nd post


Where is TTable.CommitUpdates, which must be used after TTable.ApplyUpdates.
Unrelated to the problem, but I also recommend using transaction control
through the TDatabase.  Have you considered TDatabase.ApplyUpdates rather
than TTable.ApplyUpdates?

V/R
Russell L. Smith
American Management Systems (www.amsinc.com)

Quote
Michael Glatz wrote in message <6skika$g...@forums.borland.com>...
>       try
>           tblOmsizo.delete;
>           tblOmsizo.ApplyUpdates;
>      except
>           tblOmsizo.CancelUpdates;
>           raise;
>       end;//Delete

Other Threads