[Gambas-user] Managing relationship one to many

francesco.difusco@libero.it francesco.difusco at ...69...
Mon Sep 6 14:26:25 CEST 2004


I need to manage one or more table having a relationship one to many. I select a
record in the first table, and according to this record, I read key field in
this record to select all the other records in the second table. The first
tables contains all the magazines I have bought, not their issues. For example,
in this table I have,

CodeMagazine| Title                                       |  Editor
  | City  |  ISSN
------------------------------------------------------------------------------------
1                   Dr. Dobb's Journal
2                   C/C++ Journal
3                   Linux Journal
4                   Linux Magazine
5                   Linux Magazine (Italian edition)
6                   Computer Programming
...
..
--------------------------------------------------------------------------------------
etc.

Ih the second table I have all the issues of the above magazines

CodeMagazine  IdReview Issue    PublDate   Price   Pages ...
--------------------------------------------------------
1                     101          255   May2004  8€     82
1                     102          256   June2004 8€     82
6                     103          11     Jan2002   3€     98
4                     104          34     Jul1999    2€     112
....
....
-----------------------------------------------------------

Now, when I want to display all the Dr. DObb's Journal I have, I first select
the record corresponding to Dr. Dobb's in the first table, and I get the value
of CodeMagazine, then I execute a query in the second table selecting all the
issues corresponding to the CodeMagazine I have choosen in the first table.
Hope this is clear.
Now, in Gambas, I open various tables of a mysql database in different forms.
Precisely, I open
the first table of the above example, displaying it in a tableview control.
Then, I select a record. I use a field of this record to query another table. I
pass this value to a second form I open. In the open event of this second form I
execute the second query and I get all the data correctly. I
open and display this query in the open event of the new form. It works
correctly, but when I:
move the second form up-down, or left-right or;
return to the calling form;

the application freezes, and I need to interrupt it. So I get an error message
about the field IdReview, without any other information

I tried to send a copy of the project, but it was rejected for it was too big.


Thanks

Francesco







More information about the User mailing list