Use the Delete method to delete the current record in an active dataset. When the Delete method is called,
procedure TForm1.TableBeforeDelete (Dataset: TDataset) begin if MessageDlg('Delete This Record?', mtConfirmation, mbYesNoCancel, 0) <> mrYes then Abort; end;
void __fastcall TForm1::TableBeforeDelete (TDataSet *Dataset) { if (MessageBox(0, "Delete This Record?", "CONFIRM", MB_YESNO) != IDYES) Abort(); }
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 are caching updates, the deleted record is not removed from the underlying database table until you call ApplyUpdates.
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.
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|