Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-04

Master/Detail Relation

8 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Leonardo M. Ramé
to Leonardo M. Ramé
Leonardo M. Ram? wrote 7 lines
Hi, I was looking at SqlDb components and I can't find any property to link two datasets in a Master/Detail relation, as in Delphi. Is such feature already implemented? any tutorial/wiki?. Thanks in advance, --

I found the solution.

For the record:

SqlQuery1 (master)
SqlQuery2 (detail)

In SqlQuery2.Sql.Text I had to add a "where" condition with a param, for example:

select * from a_table where a_field = :field_from_query1

The param must be a Field from SqlQuery1.

Then, by code, i had to the param type:

SQLQuery2.ParamByName('field_from_query1').DataType := ftInteger;

The last step is to point SqlQuery2.DataSource to a TDataSource associated to SqlQuery1. In my case I have two TDbGrids in form1, each grid with a TDataset pointed to SqlQuery1 and SqlQuery2, so in SqlQuery2.DataSource I assigned "form1.datasource1", and that's it.

Reply by email

Peter Williams
to Leonardo M. Ramé

Hi Leonardo,

Show quoted text 37 lines
Date: Sat, 16 Apr 2011 18:39:05 -0300 From: To: Subject: Re: [Lazarus] Master/Detail Relation On 2011-04-16 15:56:19 -0300, Leonardo M. Ram? wrote: > Hi, I was looking at SqlDb components and I can't find any property to > link two datasets in a Master/Detail relation, as in Delphi. > > Is such feature already implemented? any tutorial/wiki?. > > Thanks in advance, > -- I found the solution. For the record: SqlQuery1 (master) SqlQuery2 (detail) In SqlQuery2.Sql.Text I had to add a "where" condition with a param, for example: select * from a_table where a_field = :field_from_query1 The param must be a Field from SqlQuery1. Then, by code, i had to the param type: SQLQuery2.ParamByName('field_from_query1').DataType := ftInteger; The last step is to point SqlQuery2.DataSource to a TDataSource associated to SqlQuery1. In my case I have two TDbGrids in form1, each grid with a TDataset pointed to SqlQuery1 and SqlQuery2, so in SqlQuery2.DataSource I assigned "form1.datasource1", and that's it.

I would like to see your solution. I am wondering if you could please make a demo Lazarus project and zip it up and upload it to http://hotfile.com . It is a file sharing website and then I will be able to see your code. Thanks in advance.
Best Regards,Peter / pew

Show quoted text 9 lines
-- Leonardo M. Ram? http://leonardorame.blogspot.com -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110417/f48b67c0/attachment.html>

Reply by email

Graeme Geldenhuys
to Peter Williams

2011/4/17 Peter Williams :

I would like to see your solution. I am wondering if you could please make a demo Lazarus project and zip it up and upload it to http://hotfile.com . It is a file sharing website and then I will be able to see your code.

Why not just follow his instructions... you might learn more that way (instead of simply copy-and-pasting code).

Regards, ? - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email

Peter Williams
to Graeme Geldenhuys

Hi Graeme,

Show quoted text 13 lines
Date: Sun, 17 Apr 2011 09:53:04 +0200 From: To: Subject: Re: [Lazarus] Master/Detail Relation 2011/4/17 Peter Williams : > I would like to see your solution. I am wondering if you could please make a > demo Lazarus project and zip it up and upload it to http://hotfile.com . It > is a file sharing website and then I will be able to see your code. Why not just follow his instructions... you might learn more that way (instead of simply copy-and-pasting code).

I could not follow his instructions. And you are not help either. Best Regards,Peter / pew

Show quoted text 17 lines
-- Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110417/5108fb2d/attachment.html>

Reply by email

Graeme Geldenhuys
to Peter Williams

2011/4/17 Peter Williams :

I could not follow his instructions. And you are not help either.

I did not mean to come across as rude, I just don't think being spoon-fed is very useful. Expecting somebody else to create a fully working code example for you, is just wishful thinking. We are all busy people. From my past experience, and from looking at the programmers that work for me, copy-and-paste coding teaches nobody anything. Following some instructions, and working through the details and problems you experience along the way, is the best way of learning. You will probably remember it better for a next time too.

Regards, ? - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email

Koenraad Lelong
to Peter Williams: I would like to see your solution. I am wondering if you could please make a demo Lazarus…
Peter Williams wrote
Hi Leonardo,

...

Show quoted text 11 lines
I would like to see your solution. I am wondering if you could please make a demo Lazarus project and zip it up and upload it to http://hotfile.com . It is a file sharing website and then I will be able to see your code. Thanks in advance. Best Regards, Peter / pew

Hi,

I made an example of a master-detail-subdetail application : http://mantis.freepascal.org/view.php?id=18491. It uses the Firebird employee-database.
There is a bug in the subdetail-handling. But master-detail works fine.

HTH,

Koenraad Lelong

Reply by email

Peter Williams
to Koenraad Lelong

Hi,

Show quoted text 26 lines
Date: Sun, 17 Apr 2011 14:50:42 +0200 From: To: Subject: Re: [Lazarus] Master/Detail Relation Op 17-04-11 01:15, Peter Williams schreef: > Hi Leonardo, > ... > > I would like to see your solution. I am wondering if you could please > make a demo Lazarus project and zip it up and upload it to > http://hotfile.com . It is a file sharing website and then I will be > able to see your code. > > Thanks in advance. > > Best Regards, > Peter / pew > Hi, I made an example of a master-detail-subdetail application : http://mantis.freepascal.org/view.php?id=18491. It uses the Firebird employee-database. There is a bug in the subdetail-handling. But master-detail works fine.

Thanks. I will study it over the next few days.
Best Regards,Peter / pew

Show quoted text 10 lines
HTH, Koenraad Lelong -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110418/d4eb0c0c/attachment.html>

Reply by email