Board index » delphi » Delete not deleting

Delete not deleting

I've got a situation where I delete a record, exit the form, then come back
in, and the record is STILL THERE!!  the code is very simple:
   if MessageDlg('Delete Record, are you
sure?',mtConfirmation,[mbYes,mbNo],0) = mrYes then
      EmpTbl.Delete;

After running this, the record appears to be deleted, I can't scroll to it,
or "Find([])" it, but if I close the form, then run the form again, I can
search for the record, and it finds it!!

Any ideas?

Thanks,
Jesse

 

Re:Delete not deleting


A couple of questions:

Are you using cached updates?  If not are you calling Post after your delete (I
didn't see it in the code you sent)?

Do you have permissions on the database you are using to delete records?

********************************
Michael Glatz
glatzfa...@aol.com
mgl...@briefcase.com

Re:Delete not deleting


It could be that you're using cached updates with your query.  Try the
following after MyQuery.Delete
:
If MyQuery.UpdatesPending then
  MyQuery.ApplyUpdates;

Hope this helps.

Quote
Jesse Castleberry wrote in message ...
>I've got a situation where I delete a record, exit the form, then come back
>in, and the record is STILL THERE!!  the code is very simple:
>   if MessageDlg('Delete Record, are you
>sure?',mtConfirmation,[mbYes,mbNo],0) = mrYes then
>      EmpTbl.Delete;

>After running this, the record appears to be deleted, I can't scroll to it,
>or "Find([])" it, but if I close the form, then run the form again, I can
>search for the record, and it finds it!!

>Any ideas?

>Thanks,
>Jesse

Re:Delete not deleting


Quote
>Are you using cached updates?  If not are you calling Post after your
delete (I
>didn't see it in the code you sent)?

>Do you have permissions on the database you are using to delete records?

It is a simple Paradox type database file.  I don't know if I'm using Cached
updates or not, how do I tell?  I'm not using an BDE alias, I'm simply
setting the TTable.DatabaseName to a specified path before I open the file.

I tried the following:
Begin
    MyTable.Edit;
    MyTable.Delete;
    MyTable.Post; {blows up here with "Dataset not in edit or insert mode"}
end;

Besides this, I've never had to go into edit mode or post after a delete
before.

I don't have any restrictions set on the database as far as who can or
cannot update the file.  I wouldn't know where to go to set those anyway.

Thanks,
Jesse

Re:Delete not deleting


Hi :)

I had the same problem with Paradox-Tables.

You have to use the BDE-Function "DBISaveChanges()"

Best way to use it, is in the Post-Event or the Delete-Event of the
table(s).

Greetings

Hans-Jrgen Hahne

Other Threads