Recent

Author Topic: Program crash....(SQLite3 or ZEOS)  (Read 3816 times)

Yogrik

  • Newbie
  • Posts: 1
Program crash....(SQLite3 or ZEOS)
« on: August 06, 2006, 03:11:32 pm »
Program crash
When you open the table in TDBGrid, at a choice of any cell the program crash.
Probably a mistake in TDataSource

Code: [Select]

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, sqlite3ds,
  DB, DBGrids;

type

  { TForm1 }

  TForm1 = class(TForm)
    Datasource1: TDatasource;
    dbGrid1: TdbGrid;
    Sqlite3Dataset1: TSqlite3Dataset;
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
var
   fp : TFileStream;
begin
     if FileExists(Sqlite3Dataset1.FileName) then
        DeleteFile(Sqlite3Dataset1.FileName);
     fp := TFileStream.Create(Sqlite3Dataset1.FileName,fmCreate);
     fp.Free;
     SQLite3Dataset1.QuickQuery('CREATE TABLE test(col1 VARCHAR, col2 VARCHAR, col3 VARCHAR, col4 VARCHAR);');
     Sqlite3Dataset1.QuickQuery('INSERT INTO test VALUES("row10","row11","row12","row13");');
     Sqlite3Dataset1.QuickQuery('INSERT INTO test VALUES("row20","row21","row22","row23");');
     Sqlite3Dataset1.TableName := 'Test';
     Sqlite3Dataset1.Active := true;
end;

initialization
  {$I unit1.lrs}

end.