Page 1 of 1

Master / Detail with Zeos

Posted: 19.01.2012, 14:54
by elidorio2
Hello,
Please, someone teach me how to do a Master / Detail with Zeos.
Because it is a very basic example, just want to understand the concept of Zeos.


Thank you;
Edson

Posted: 15.02.2012, 13:12
by mparak
Hi Edson,

This very simple.

Form1.test_Master_Detail;
var Master,Detail:TzQuery ds_Master:TDatasource;
Begin
try
Master:=TzQuery.Create(application);
Master.connection:=Zconnection1;
Detail:=TzQuery.Create(application);
detail.connection:=Zconnection1;
ds_Master:=TDatasource.Create(application);
Master.sql.text:='select * from master_table';
Master.OPen;
ds_Master.dataset:=Master;
detail.datasource:=ds_Master;
detail.sql.text:='select * from detail_table where linkField=:linkField';
detail.open;
{
Master and detail are now opened and linked perfectly. Enjoy!
}
finally Master.free;Detail.free;ds_Master.free; end;
end;