GetDatabaseNames documentation

Discussion of open issues, suggestions and bugs regarding LiteDAC (SQLite Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
nszmnsky
Posts: 11
Joined: Wed 21 May 2014 17:07

GetDatabaseNames documentation

Post by nszmnsky » Wed 08 Nov 2017 15:23

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

MaximG
Devart Team
Posts: 1030
Joined: Mon 06 Jul 2015 11:34

Re: GetDatabaseNames documentation

Post by MaximG » Mon 13 Nov 2017 10:18

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;

Post Reply