procedure TADOConnection.GetTableNames(List: TStrings;
SystemTables: Boolean);
var
TypeField,
NameField: TField;
TableType: string;
DataSet: TADODataSet;
begin
CheckActive;
DataSet := TADODataSet.Create(nil);
try
OpenSchema(siTables, EmptyParam, EmptyParam, DataSet);
TypeField := DataSet.FieldByName('TABLE_TYPE'); { do not localize }
NameField := DataSet.FieldByName('TABLE_NAME'); { do not localize }
List.BeginUpdate;
try
List.Clear;
while not DataSet.EOF do
begin
TableType := TypeField.AsString;
if (TableType = 'TABLE') or (TableType = 'VIEW') or { do not localize }
(SystemTables and (TableType = 'SYSTEM TABLE')) then { do not localize }
List.Add(NameField.AsString);
DataSet.Next;
end;
finally
List.EndUpdate;
end;
finally
DataSet.Free;
end;
end;
在sql server 中你可以使用sql语句
select name from sysobjects where xtype = 'U'
--------------------------------------
看!
那支正飞向太阳的蛾子.....
就是我!
--------------------------------------