Datatype of Fields in sqlite Database Table (SOLVED) lazarus / 16-Databases ---------------------------------------------------------------------- Dzandaa · 2026-02-16 16:04 Hi everybody, Is it a way to retrieve the Datatype of Fields in a Sqlite Database in a TStringList? Like PRAGMA table_info('table_name') or SELECT sql FROM sqlite_master WHERE name = 'employees' (that works, but it change my TDBGrid and I want to just have the datatype). Thank you B-> ---------------------------------------------------------------------- cdbc · 2026-02-16 16:44 Hi Hmmm, in sqlite3 program, one can use '.schema' to see the structure of the tables within... I'm wondering if it is possible to do that via your 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 SELECT schema FROM sqlite_master WHERE name = 'employees';Just a thought Regards Benny ---------------------------------------------------------------------- Hansvb · 2026-02-16 17:10 Hi, This code gets the fieldnames and type of a SQLite table. 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 unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, SQLite3Conn, Forms, Controls, Graphics, Dialogs, StdCtrls,  SQLDB; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    Memo1: TMemo;    SQLite3Connection1: TSQLite3Connection;    SQLQuery1: TSQLQuery;    procedure Button1Click(Sender: TObject);  private    procedure GetTableFieldsInfo(const DatabaseName, TableName: string);  public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);begin  GetTableFieldsInfo('C:\Users\Hans\AppData\Roaming\Test\AppDB.db', 'MAATREGEL');end; procedure TForm1.GetTableFieldsInfo(const DatabaseName, TableName: string);var  Conn: TSQLite3Connection;  Trans: TSQLTransaction;  Query: TSQLQuery;begin  Conn:= TSQLite3Connection.Create(nil);  Trans:= TSQLTransaction.Create(nil);  Query:= TSQLQuery.Create(nil);  try    Conn.DatabaseName:= DatabaseName;    Conn.Transaction:= Trans;    Query.DataBase:= Conn;     Conn.Open;    Trans.StartTransaction;     Query.SQL.Text:= 'PRAGMA table_info("' + TableName + '")';    Query.Open;     while not Query.EOF do    begin      // send fieldtypes to the memo      Memo1.Lines.Add('Field: ' + Query.FieldByName('name').AsString +                ' - Type: ' + Query.FieldByName('type').AsString);      Query.Next;    end;     Query.Close;    Trans.Commit;  finally    Query.Free;    Trans.Free;    Conn.Free;  end;end; end.  Edit, i Know, i should a parameter, but this is quick and dirty. ---------------------------------------------------------------------- Zvoni · 2026-02-17 07:53 Quote from: cdbc on February 16, 2026, 05:44:18 pmI'm wondering if it is possible to do that via your 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 SELECT schema FROM sqlite_master WHERE name = 'employees';Just a thought Regards Benny No, not possible. --> "No such Column: schema" In general: Best bet are the 2 PRAGMA's table_info and table_xinfo (This one returns more info) It returns what you need. the "SELECT sql FROM sqlite_master"-approach involves parsing the returned CREATE TABLE-Statement. QuoteEdit, i Know, i should a parameter, but this is quick and dirty.And no: You can't use parameters in a PRAGMA ---------------------------------------------------------------------- Dzandaa · 2026-02-17 12:46 Hi everybody, Thank you for the suggestions. I's working now. B->