Board index » delphi » Deleting all records from file

Deleting all records from file


2006-03-27 04:58:20 AM
delphi100
Having trouble with deleting records.
Using code to empty table:
DM.TblTemp.Open;
while not DM.TblTemp.eof do
DM.TblTemp.Delete;
DM.TblTemp.Close;
Have also tried: DeleteFile('DM.TblTemp.db') but it gives exactly the
same result
When inspect DM.TblTemp with breakpoint later, it is empty.
When I append single record I get several records, ending with the last one
from previous run.
DM.TblTemp.Open;
DM.TblTemp.Append;
DM.TblTemp.FieldByName('LastName').Text:='Example';
(inspection of file here shows empty)
DM.TblTemp.Post;
(inspection here shows 10 or more 'Example's)
Is there a better way of emptying that table?
 
 

Re:Deleting all records from file

Oh, I don't know, perhaps TTable.EmptyTable! Suggestion: the Delphi Help
file.
"John Hargreaves" <XXXX@XXXXX.COM>writes
Quote
Having trouble with deleting records.

Using code to empty table:

DM.TblTemp.Open;
while not DM.TblTemp.eof do
DM.TblTemp.Delete;
DM.TblTemp.Close;

Have also tried: DeleteFile('DM.TblTemp.db') but it gives exactly the
same result

When inspect DM.TblTemp with breakpoint later, it is empty.

When I append single record I get several records, ending with the last
one from previous run.

DM.TblTemp.Open;
DM.TblTemp.Append;
DM.TblTemp.FieldByName('LastName').Text:='Example';
(inspection of file here shows empty)
DM.TblTemp.Post;
(inspection here shows 10 or more 'Example's)

Is there a better way of emptying that table?