要咱清空一个有接近100张表的数据库,手工一张一张的清空,烦!
尝试以下代码可实现 。记得备份数据
var Form10: TForm10;
implementation
{$R *.dfm}
procedure TForm10.Button1Click(Sender: TObject); var i :integer; begin for i:=0 to ListBox1.Items.Count-1 do try FDQuery1.SQL.Text:='DELETE FROM ' +ListBox1.Items.Strings[i]; FDQuery1.open; except //有部份无法删除 end; end;
procedure TForm10.FormCreate(Sender: TObject); begin FDConnection1.GetTableNames('', '', '', ListBox1.Items);
end;
end.