[Solved] SQLite | GetTableNames desnt work lazarus / 16-Databases ---------------------------------------------------------------------- cpalx · 2018-02-14 18:31 hello, i use TSQLite3Connection and i need The tebles names, so i use TSQLite3Connection.GetTableNames(a Tstrings) and i get a memory error any idea? ---------------------------------------------------------------------- molly · 2018-02-14 18:47 Quote from: cpalx on February 14, 2018, 07:31:28 pmany idea? without any code and exact error message ?, no idea. In that case your guess is as good as mine.... Shot in the dark: you did not create your stringlist before passing it along to method GetTableNames... ---------------------------------------------------------------------- cpalx · 2018-02-15 02:06 ================ Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  SQLiteConn:= TSQLite3Connection.Create( nil );  Query:= TSQLQuery.Create( nil );  SQLiteTran:= TSQLTransaction.Create( nil );  SQLiteConn.Transaction:= SQLiteTran;  Query.Transaction:= SQLiteTran;  SQLiteTran.Action:= caCommitRetaining;  Query.DataBase:= SQLiteConn;  Error:= EmptyStr;   if DataBaseName = DBName then     DataBaseName:= ExtractFilePath( ParamStr( 0 ) ) + DBName ;   SQLiteConn.DatabaseName:= DataBaseName ;   try     SQLiteConn.Connected:= True;     Self.Connected:= SQLiteConn.Connected;   except on E: Exception do begin     Error:= E.ClassName + LineEnding + E.Message;     Self.Connected:= False;  end;  end;                            ================ ================ Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TSQLiteCache.GetTableNames( var List: Tstrings; ShowSystemTables: Boolean = False ): Boolean;begin   try   SQLiteConn.GetTableNames( List, ShowSystemTables );   result:= true  except on E: Exception do begin     Error:= E.ClassName + LineEnding + E.Message;     Result:= False;  end;  end;end;    ================ and i call: ============== Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var ListTableName: Tstrings;begin   ListTableName:= TStrings.Create;   if not  Cache.GetTableNames( ListTableName ) then      ShowMessage( Cache.Error );   ============== And display error: ============== EAbstractError Abstract method called ============== ---------------------------------------------------------------------- molly · 2018-02-15 02:17 Quote from: cpalx on February 15, 2018, 03:06:43 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var ListTableName: Tstrings;begin   ListTableName:= TStrings.Create;   if not  Cache.GetTableNames( ListTableName ) then      ShowMessage( Cache.Error );   ============== And display error: ============== EAbstractError Abstract method called ============== Don't create directly from TStrings It is an abstract class. The warnings during compilation should have given you that hint. Quote... Warning: Constructing a class "TStrings" with abstract method "Get" ... Warning: Constructing a class "TStrings" with abstract method "GetCount" ... Warning: Constructing a class "TStrings" with abstract method "Clear" ... Warning: Constructing a class "TStrings" with abstract method "Delete" ... Warning: Constructing a class "TStrings" with abstract method "Insert" use: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var ListTableName: TstringList;begin   ListTableName:= TStringList.Create;   if not  Cache.GetTableNames( ListTableName ) then      ShowMessage( Cache.Error ); more information. TStrings: QuoteTStrings implements an abstract class to manage an array of strings. It introduces methods to set and retrieve strings in the array, searching for a particular string, concatenating the strings and so on. It also allows an arbitrary object to be associated with each string. It also introduces methods to manage a series of name=value settings, as found in many configuration files. An instance of TStrings is never created directly, instead a descendant class such as TStringList should be created. This is because TStrings is an abstract class which does not implement all methods; TStrings also doesn't store any strings, this is the functionality introduced in descendants such as TStringList. ---------------------------------------------------------------------- cpalx · 2018-02-15 02:22 Thanks Molly, problem solved ---------------------------------------------------------------------- molly · 2018-02-15 02:37 You're welcome cpalx. Another approach is also possible: Code: [Select]var ListTableName: Tstrings; begin   ListTableName:= TStringList.Create;   if not  Cache.GetTableNames( ListTableName ) then   ShowMessage( Cache.Error ); end; In which case you could keep the TStrings var parameter for TSQLiteCache.GetTableNames. I would personally not opt for it in your case though as using TStringlist as var parameter makes things more explicit. btw: classes are passed by reference by default, so no need for using var modifier. ---------------------------------------------------------------------- cpalx · 2018-02-15 02:46 Thanks for your advice, i changed the params by TStringList