I can't get the table names from databases other than the database specified in connection's params.
First, I used GetTableNames and it worked fine, but I was specifying the same database from connection's params.
DM.FDConnection.GetTableNames(ADatabse, '', APattern, tables, [osMy], [tkTable], False);
But when I tried to specify other database, I did not work. Then, I tried to use the TFDMetaInfoQuery, but it did not work either:
FDMetaInfoQuery := TFDMetaInfoQuery.Create(nil);
FDMetaInfoQuery.Connection := DM.FDConnection;
FDMetaInfoQuery.MetaInfoKind := mkTables;
FDMetaInfoQuery.CatalogName := 'databasename'
FDMetaInfoQuery.Open;
while not FDMetaInfoQuery.Eof do
begin
Result := Result + sLineBreak + FDMetaInfoQuery.FieldByName('TABLE_NAME').AsString;
FDMetaInfoQuery.Next;
end;
But I can get all the databases name:
FDMetaInfoQuery := TFDMetaInfoQuery.Create(nil);
FDMetaInfoQuery.Connection := DM.FDConnection;
FDMetaInfoQuery.MetaInfoKind := mkCatalogs;
FDMetaInfoQuery.Open;
while not FDMetaInfoQuery.Eof do
begin
Result := Result + sLineBreak + FDMetaInfoQuery.FieldByName('CATALOG_NAME').AsString;
FDMetaInfoQuery.Next;
end;
I already tried to specify those param in the connection, but nothing changed:
DM.FDConnection.Params.Add('MetaDefSchema=*');
DM.FDConnection.Params.Add('MetaDefCatalog=*');
DM.FDConnection.Params.Add('MetaCurSchema=*');
DM.FDConnection.Params.Add('MetaCurCatalog=*');
So, how should I get the table names from others databases?
I found out, my very question is the answer.. I should include osOther in the TFDPhysObjectScopes..
DM.FDConnection.GetTableNames(ADatabse, '', APattern, tables, [osMy, osOther], [tkTable], False);