ovo je code ,problem mi stvara dio za punjenje grida
ds.DataSet:=query;
DBGrid1.DataSource:=ds;
dobijem poruku: project project1 raised exception class External SIGSEGV
Code:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
DBGrids, DbCtrls, Grids, sqldb, postgres, pqconnection,db;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
DBGrid1: TDBGrid;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
conn : TPQConnection;
query : TSQLQuery;
transaction : TSQLTransaction;
dt : TDataSet;
ds : TDatasource;
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
S: String;
begin
conn := TPQConnection.Create(nil);
query := TSQLQuery.Create(nil);
transaction := TSQLTransaction.Create(nil);
try
try
conn.HostName := '127.0.0.1';
conn.UserName := 'postgres';
conn.Password := 'postgres';
conn.DatabaseName := 'postgres';
conn.Connected := True;
conn.Transaction := transaction;
query.DataBase := conn;
//query.ParseSQL := true; //line not needed - this is the default anyway
//query.ReadOnly := false; //line not needed - this is the default anyway
query.SQL.Text := 'select * from proba';
// query.Open;
// query.Last;
// S := IntToStr(query.RecordCount) + #13#10;
// query.First;
// while not query.EOF do
// begin
// S := S + query.FieldByName('prva').AsString + #13#10;
// query.Next;
// end;
begin
// query.open;
ds.DataSet:=query;
DBGrid1.DataSource:=ds;
// query.close;
end ;
finally
query.Free;
conn.Free;
end;
except
on E: Exception do
ShowMessage(E.message);
end;
Memo1.Text:= S;
end;
end.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
DBGrids, DbCtrls, Grids, sqldb, postgres, pqconnection,db;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
DBGrid1: TDBGrid;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
conn : TPQConnection;
query : TSQLQuery;
transaction : TSQLTransaction;
dt : TDataSet;
ds : TDatasource;
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
S: String;
begin
conn := TPQConnection.Create(nil);
query := TSQLQuery.Create(nil);
transaction := TSQLTransaction.Create(nil);
try
try
conn.HostName := '127.0.0.1';
conn.UserName := 'postgres';
conn.Password := 'postgres';
conn.DatabaseName := 'postgres';
conn.Connected := True;
conn.Transaction := transaction;
query.DataBase := conn;
//query.ParseSQL := true; //line not needed - this is the default anyway
//query.ReadOnly := false; //line not needed - this is the default anyway
query.SQL.Text := 'select * from proba';
// query.Open;
// query.Last;
// S := IntToStr(query.RecordCount) + #13#10;
// query.First;
// while not query.EOF do
// begin
// S := S + query.FieldByName('prva').AsString + #13#10;
// query.Next;
// end;
begin
// query.open;
ds.DataSet:=query;
DBGrid1.DataSource:=ds;
// query.close;
end ;
finally
query.Free;
conn.Free;
end;
except
on E: Exception do
ShowMessage(E.message);
end;
Memo1.Text:= S;
end;
end.