* * *

Author Topic: Emptying TBufDataSet  (Read 563 times)

egsuh

  • New member
  • *
  • Posts: 31
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,

GetMem

  • Hero Member
  • *****
  • Posts: 2618
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: 7781
  • 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.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus