var SL:TStrings; index:integer; begin SL:=TStringList.Create ; Try //返回数据库表名 form1.ADOConnection1.GetTableNames(SL,False); for index:=0 to (SL.Count -1) do begin form1.Adotable1.TableName :=SL[index]; form1.ListBox1 .Items.Add(SL[index]); end; finally SL.Free; end; listbox1.Show; 得到表名后循环判断是否存在 listbox1中存了表名
function ExistTable(cnn:TADOConnection;TableName:string): boolean; var tables:Tstrings; begin Result:=False ; tables:= TStringList.Create ; try cnn.GetTableNames(tables); if tables.IndexOf(TableName)>-1 then Result:=True ; finally tables.Free ; end; end;
SL:TStrings;
index:integer;
begin
SL:=TStringList.Create ;
Try
//返回数据库表名
form1.ADOConnection1.GetTableNames(SL,False);
for index:=0 to (SL.Count -1) do
begin
form1.Adotable1.TableName :=SL[index];
form1.ListBox1 .Items.Add(SL[index]);
end;
finally
SL.Free;
end;
listbox1.Show;
得到表名后循环判断是否存在
listbox1中存了表名
ExistTable (tablename) :boolean 的函数?
万分感激。
var
tables:Tstrings;
begin
Result:=False ;
tables:= TStringList.Create ;
try
cnn.GetTableNames(tables);
if tables.IndexOf(TableName)>-1 then
Result:=True ;
finally
tables.Free ;
end;
end;