procedure TForm1.Button1Click(Sender: TObject);
var
TableList:TstringList;
TableName:string;
begin
TableName:='Table1';
try
TableList:=Tstringlist.Create;
LogADOConnection1.GetTableNames(TableList);
if TableList.IndexOf(TableName)>=0 then//如果表存在
with ADOCommand1 do
begin
CommandText:='drop table '+TableName;
execute;
end;
except
Raise Exception.Create('删除操作失败!');
end;
end;
var
TableList:TstringList;
TableName:string;
begin
TableName:='Table1';
try
TableList:=Tstringlist.Create;
LogADOConnection1.GetTableNames(TableList);
if TableList.IndexOf(TableName)>=0 then//如果表存在
with ADOCommand1 do
begin
CommandText:='drop table '+TableName;
execute;
end;
except
Raise Exception.Create('删除操作失败!');
end;
end;
if exists (select * from sysobjects where id = object_id(N'[表名]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [表名]