Delphi Database, Delphi Components from ComponentAce
Products Download Order Contact us
Deleting Records
Previous  Top  Next



Use the Delete method to delete the current record in an active dataset.When the Delete method is called,

·The dataset receives a BeforeDelete event.  
·The dataset attempts to delete the current record.  
·The dataset returns to the dsBrowse state.  
·The dataset receives an AfterDelete event.  

If want to prevent the deletion in the BeforeDelete event handler, you can call the global Abort procedure:

procedure TForm1.TableBeforeDelete (Dataset: TDataset)begin
  if MessageDlg('Delete This Record?'
, mtConfirmation, mbYesNoCancel, 0) <> mrYes then
    Abort;
end;

If Delete fails, it generates an OnDeleteError event. If the OnDeleteError event handler can't correct the problem, the dataset remains in dsEdit state. If Delete succeeds, the dataset reverts to the dsBrowse state and the record that followed the deleted record becomes the current record.
If you provide a navigator component on your forms, users can delete the current record by clicking the navigator's Delete button. In code, you must call Delete explicitly to remove the current record.
        © 2003 - 2017 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Apr 29, 2017