Recent

Author Topic: Emptying TBufDataSet  (Read 2625 times)

egsuh

  • Hero Member
  • *****
  • Posts: 1273
Emptying TBufDataSet
« on: January 12, 2018, 04:25:54 pm »
Hi,
TBufDataSet does not have any methods like EmptyTable or EmptyDataSet. So I wrote a quick procedure as follows:

procedure EmptyDataSet(ADataSet:TDataSet);
begin
   ADataSet.Active := True;
   ADataSet.First;
   While not ADataSet.Eof do ADataSet.Delete;
   ADataSet.Close;
end;

This works fine for my purpose for now. But I'd like to ask you whether this procedure is applicable to all other datasets, and does not have any problem (which I don't know).  Also welcome any other suggestions for this purpose.

Regards,

balazsszekely

  • Guest
Re: Emptying TBufDataSet
« Reply #1 on: January 12, 2018, 04:43:33 pm »
Use a query, like this:
Code: Pascal  [Select][+][-]
  1.  SQLQuery1.SQL.Text := 'delete from Your_TableName';
  2.  SQLQuery1.ExecSQL;
  3.  //commit

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Emptying TBufDataSet
« Reply #2 on: January 13, 2018, 06:11:42 pm »
Use a query, like this:
Code: Pascal  [Select][+][-]
  1.  SQLQuery1.SQL.Text := 'delete from Your_TableName';
  2.  SQLQuery1.ExecSQL;
  3.  //commit
If rollback is not needed, truncate table actually works a lot faster.

 

TinyPortal © 2005-2018