[Lazarus] Master/Detail Relation

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Master/Detail Relation

Leonardo M. Ramé
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,
--
Leonardo M. Ramé
http://leonardorame.blogspot.com

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Master/Detail Relation

Leonardo M. Ramé
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.

--
Leonardo M. Ramé
http://leonardorame.blogspot.com

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Master/Detail Relation

Peter Williams
Hi Leonardo,

> Date: Sat, 16 Apr 2011 18:39:05 -0300
> From: [hidden email]
> To: [hidden email]
> 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

> --
> Leonardo M. Ramé
> http://leonardorame.blogspot.com
>
> --
> _______________________________________________
> Lazarus mailing list
> [hidden email]
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Master/Detail Relation

Graeme Geldenhuys
2011/4/17 Peter Williams <[hidden email]>:
> 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

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Master/Detail Relation

Peter Williams
Hi Graeme,

> Date: Sun, 17 Apr 2011 09:53:04 +0200
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [Lazarus] Master/Detail Relation
>
> 2011/4/17 Peter Williams <[hidden email]>:
> > 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

>
>
>
> --
> Regards,
>   - Graeme -
>
>
> _______________________________________________
> fpGUI - a cross-platform Free Pascal GUI toolkit
> http://fpgui.sourceforge.net
>
> --
> _______________________________________________
> Lazarus mailing list
> [hidden email]
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Master/Detail Relation

Graeme Geldenhuys
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

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Master/Detail Relation

Koenraad Lelong
In reply to this post by Peter Williams
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.

HTH,

Koenraad Lelong

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Master/Detail Relation

Peter Williams
Hi,

> Date: Sun, 17 Apr 2011 14:50:42 +0200
> From: [hidden email]
> To: [hidden email]
> 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

>
> HTH,
>
> Koenraad Lelong
>
> --
> _______________________________________________
> Lazarus mailing list
> [hidden email]
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus