Learning DB Question lazarus / 31-LCL ---------------------------------------------------------------------- greertr · 2017-01-01 14:39 I'm trying to learn db programming using the A Level site... http://alevel-computing.x10.mx/TutorialLazarusSQLite.php Everything is going to plan except, when I connect, the data doesnt properly populate the dbgrid.  A couple of screenies are attached to show it. The db fiield types are all text -- I tried char and varchar, but same thing happens. Here is the unit code... 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, sqldb, db, FileUtil, Forms, Controls,  Graphics, Dialogs, DBGrids, StdCtrls; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    Button2: TButton;    DataSource1: TDataSource;  DBGrid1: TDBGrid;    Edit1: TEdit;    Label1: TLabel;    SQLite3Connection1: TSQLite3Connection;    SQLQuery1: TSQLQuery;    SQLTransaction1: TSQLTransaction;    procedure Button1Click(Sender: TObject);    procedure Button2Click(Sender: TObject);  private    { private declarations }  public    { public declarations }  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);begin  SQLite3Connection1.DatabaseName:='A.db';  SQLite3Connection1.Transaction:=SQLTransaction1;   SQLTransaction1.Database:=SQLite3Connection1;   SQLQuery1.Database:=SQLite3Connection1;  SQLQuery1.Transaction:=SQLTransaction1;  SQLQuery1.SQL.Text:='SELECT * FROM Student';   Datasource1.dataset:=SQLQuery1;  DBGrid1.DataSource:=DataSource1;  SQLite3Connection1.Open;  If SQLite3Connection1.Connected then  begin    Label1.caption:='connected -great';  end;  SQLQuery1.open;end; procedure TForm1.Button2Click(Sender: TObject);begin  SQLQuery1.Close;  SQLQuery1.SQL.text:=edit1.text;  SQLQuery1.Open;end;   end.  Can anyone explain what I'm doing wrong? thx in adv ---------------------------------------------------------------------- marcov · 2017-01-01 15:13 For these fields set the gettext field to an event that looks like: 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 procedure TSqlCreateFrm.defaultgettext(Sender: TField; var Textit: string;  DisplayText: Boolean);begin    if DisplayText then     Textit := Copy(sender.AsString, 1, 50)  else     Textit:=sender.AsString;end;   Check the FPC/Lazarus wiki for more db tips and tricks http://wiki.freepascal.org/SQLitehttp://wiki.freepascal.org/Lazarus_Da tabase_Overviewhttp://wiki.freepascal.org/SqlDBHowto ---------------------------------------------------------------------- greertr · 2017-01-01 15:26 thx Marcov, but ".defaultgettext" causes an error when i make the forward declaration. ---------------------------------------------------------------------- greertr · 2017-01-01 16:02 p.s.  I changed all the db fields to varchar and now it works correctly.