uses
DB, DBTables, DbiProcs, DbiErrs, DbiTypes;
procedure DeleteTable(Dir, TblName: String);
var
DBHandle: HDBIDB;
ResultCode: DBIResult;
tbl, Err: Array[0..255] of Char;
SrcTbl: TTable;
begin
SrcTbl := TTable.Create(Application);
try
SrcTbl.DatabaseName := Dir;
SrcTbl.TableName := TblName;
SrcTbl.Open;
DBHandle := SrcTbl.DBHandle;
SrcTbl.Close;
ResultCode := DbiDeleteTable(DBHandle,
StrPCopy(Tbl,Dir + '\' + TblName), nil);
if ResultCode <> DBIERR_NONE then
begin
DbiGetErrorString(ResultCode,Err);
raise EDatabaseError.Create('While deleting ' +
Dir + '\' + TblName + ', the database ' +
'engine generated the error ''' + StrPas(Err) + '''');
end;
finally
SrcTbl.Free;
end;
end;
|