Try this to reindex
begin
charges.open;
charges.active:=false;
try
if FileExists('charges.mdx') then
begin
charges.deleteindex('chrgno');
charges.deleteindex('inv');
end;
finally
charges.addindex('chrgno','id',[]);
charges.addindex('inv','invoice',[]);
end;
It works for me
Packing tables is not so easy to explain but try this
In the uses list include
DbiTypes, DbiProcs, DbiErrs;
In the var list
Error: DbiResult;
ErrorMsg: String;
Special: DBIMSG;
For a table called cattle
cattle.Active := False;
cattle.Exclusive := True;
cattle.Active := True;
Error := DbiPackTable(cattle.DBHandle, cattle.Handle, nil, szdBASE,
True);
cattle.Active := False;
cattle.Exclusive := False;
To handle errors
case Error of
DBIERR_NONE:
ErrorMsg := 'Successful';
DBIERR_INVALIDPARAM:
ErrorMsg := 'The specified table name or the pointer to the ' +
'table name is NULL';
DBIERR_INVALIDHNDL:
ErrorMsg := 'The specified database handle or cursor handle is ' +
'invalid or NULL';
DBIERR_NOSUCHTABLE:
ErrorMsg := 'Table name does not exist';
DBIERR_UNKNOWNTBLTYPE:
ErrorMsg := 'Table type is unknown';
DBIERR_NEEDEXCLACCESS:
ErrorMsg := 'The table is not open in exclusive mode';
else
DbiGetErrorString(Error, Special);
ErrorMsg := '[' + IntToStr(Error) + ']: ' + Special;
end;
MessageDlg(ErrorMsg, mtWarning, [mbOk], 0);
There may be an easier way but this works for me
Sandy Ferguson
HIPER SOFTWARE
If you still have a problem email me.
Quote
Craig Kinsman wrote in message <7csmhi$l0...@news.iinet.net.au>...
>Hi people,
>Using Delphi C/S 3.0 on NT4(SP3).
>I'm manipulating DBase3 files using TTables and need to be able to
>1) pack the .dbf files to get rid of deletions
>2) re-create the NDX indices
>(so that another application can be launched with the files in a good
>state).
>I can't see any way of doing this in Delphi - surely it's possible??
>Any suggestions gratefully received,
>Craig.