Page 1 of 1

GetDatabaseNames documentation

Posted: Wed 08 Nov 2017 15:23
by nszmnsky
I'm getting error when I try to use TCustomDAConnection.GetDatabaseNames in Firemonkey.

Code: Select all

var
  DBlist:TStrings;
  LTS:string;
begin
  DBList:=TStringList.create;
  try
    CRTT.GetDatabaseNames(DBlist); //GetTableNames(DBlist,false,true);
    if(DBlist.Count=1)
    then begin
        LTS := DBM.CRTT.Database;
        LTS := leftstr(LTS,length(LTS)-3)+' - Data.db';
        DBM.LiteSQL1.SQL.Clear;
        DBM.LiteSQL1.SQL.Add('ATTACH DATABASE "'+LTS+'" as "LTS";');
        DBM.LiteSQL1.Execute;
    end;
  finally
    DBlist.Free;
  end;
When using the GetDatabaseNames I get an "Unsupported metadata kind", however the GetTableNames does work and returns the number of tables in the Main db.

I didn't find online documentation, can you provide example of proper use of GetDatabaseNames?

Thanks
Neil

Re: GetDatabaseNames documentation

Posted: Mon 13 Nov 2017 10:18
by MaximG
It's true, this functionality is not implemented in LiteDAC, the message you receive is an evidence of this. This is due to specificity of SQLite itself. The GetDatabaseNames method is designed to obtain a list of available databases to which the used server allows you to connect. SQLite only allows getting a list of databases connected to the current connection. To get the information you need, in LiteDAC instead of the GetDatabaseNames method, you can use the following query:

Code: Select all

pragma database_list;