Grandfather - Father - Son linked tables, son stops updating lazarus / 16-Databases ---------------------------------------------------------------------- daveinhull · 2014-06-19 22:39 Hi, I'm hoping someone can help with a database problem I'm having. I'll firstly just explain at a high'ish level to see if the problem is immediately obvious to anyone then provide more details if necessary. I am just exploring Lazarus and databases, and how they work. I have three tables in an Access database linked to 3 grids in a Lazarus program. I started with 2 tables and they work great, I can move around, add records (including those with auto numbers) etc. When I add a new record to the grandfather table, the father table goes to a new record and then when I go back up the grandfather records, the father records show again, all as would be expected. I then added a son table linked to the father table. I set up some initial data so that there were records in all tables that linked together (the Access database has appropriate relationships). When I first run the program I get data in all three tables and with a valid link between grandfather and father I can move up and down the father records and the son records change as expected. However, and here is the problem, when I move the grandfather record down to where there isn't a father record, I get the new record in the father table (as expected) but the son table goes completely blank (which is probably expected, although it might have gone to a new record). The real problem is that when I move the grandfather table to a record that does exist in the father table which does link to a record in the son table, the son table remains completely blank and I can never get back any records. Anyone any thoughts? Many thanks in advance Dave ---------------------------------------------------------------------- Stephano · 2014-06-20 15:33 If my memory serves well, this is a very old bug which hasn't been fixed yet. Michael tried to fix it at one point. Maybe if you an open a bug report with an example, some devs might take a deeper look. ---------------------------------------------------------------------- LuizAmérico · 2014-06-21 11:43 What component are you using? ---------------------------------------------------------------------- Stephano · 2014-06-21 14:05 I found a bug report that somebody else had submitted: http://bugs.freepascal.org/view.php?id=18491 ---------------------------------------------------------------------- daveinhull · 2014-06-21 17:15 Quote from: Stephano on June 20, 2014, 05:33:55 pmIf my memory serves well, this is a very old bug which hasn't been fixed yet. Michael tried to fix it at one point. Maybe if you an open a bug report with an example, some devs might take a deeper look. Thanks for the quick response. Quote from: LuizAmérico on June 21, 2014, 01:43:47 pmWhat component are you using? TODBCConnection, TSQLTransaction, TDataSource, TSQLQuery and  TBGrid. DBGrid3 (child): Datasource3 -> Dataset3 -> SQL3 -> Database -> Connection1 & Datasource -> Datasource2 (father) DBGrid2 (father) Datasource2 -> Dataset2 -> SQL2 -> Database -> Connection1 & Datasource -> Dataseouce1 (grandfather) DBGrid1 (grandfather) Datasource2 -> Dataset1 -> SQL1 -> Database -> Connection1 & Datasource -> blank All SQLs have transactions point to the same transaction as DBGrid1 This is probably not the best way to describe the links, but it might help. Quote from: Stephano on June 21, 2014, 04:05:28 pmI found a bug report that somebody else had submitted: http://bugs.freepascal.org/view.php?id=18491 Very similar I think. Does anyone know a work around? Thanks Dave ---------------------------------------------------------------------- BigChimp · 2014-06-22 06:05 Quote from: daveinhull on June 21, 2014, 07:15:50 pmQuote from: Stephano on June 21, 2014, 04:05:28 pmI found a bug report that somebody else had submitted: http://bugs.freepascal.org/view.php?id=18491 Very similar I think. You can take the chance the issue is the same or submit a new bug report with an example project. In the latter case, the worst that can happen is that the bug report will be marked as a duplicate of the other issue. Strange that that bug report didn't see any activity all those years... I'd think we'll need to look into this. ---------------------------------------------------------------------- daveinhull · 2014-06-22 12:55 Quote from: BigChimp on June 22, 2014, 08:05:16 amQuote from: daveinhull on June 21, 2014, 07:15:50 pmQuote from: Stephano on June 21, 2014, 04:05:28 pmI found a bug report that somebody else had submitted: http://bugs.freepascal.org/view.php?id=18491 Very similar I think. You can take the chance the issue is the same or submit a new bug report with an example project. In the latter case, the worst that can happen is that the bug report will be marked as a duplicate of the other issue. Strange that that bug report didn't see any activity all those years... I'd think we'll need to look into this. Ok, but as this is my first time, could you point me to where I log bugs? Also, what type of information should I submit, just a zipped version of the project folder? I do have a nice neat simply example of the problem. Many thanks Dave ---------------------------------------------------------------------- BigChimp · 2014-06-22 14:22 See the link to the left under Lazarus: Bugtracker, then create an account and an issue. Yes, please fill out all the fields in the issue, describe it and attaching a zipped project source with required mdb files would be great. Thanks a lot ---------------------------------------------------------------------- daveinhull · 2014-06-23 08:29 OK thanks, will do...... Dave ---------------------------------------------------------------------- daveinhull · 2015-02-10 23:22 Hi All, As suggested I posted a bug report back in June last year (0026424), but its still outstanding and so I've not really been able to progress with my Pascal development. Can anyone take a look at this bug as I'd very much like to get back into working on my application. Many thanks Dave ---------------------------------------------------------------------- LacaK · 2015-02-11 11:44 I uploaded patch to http://bugs.freepascal.org/view.php?id=26424 So you can test it. ---------------------------------------------------------------------- daveinhull · 2015-02-18 12:25 Hi, Ok, it looks as if the problem has been fixed as the bug has been closed, but what do I do now? The bug says that it is fixed in revision 29679 with 2015-02-13 08:31  Michael Van Canneyt    Fixed in Version  => 3.1.1  2015-02-13 08:31  Michael Van Canneyt    Resolution  open => fixed  2015-02-13 08:31  Michael Van Canneyt    Target Version  => 3.0.0  2015-02-13 09:40  Michael Van Canneyt    Relationship added  related to 0018491  How do I get this revision? as the latest version looks like 2.6.4? Any help would be appreciated Many thanks Dave ---------------------------------------------------------------------- goodname · 2015-02-20 22:37 The patch is targeted for FPC 3.0 which is currently going through stabilization. You can either wait for the stable release, compile FPC 3.0 and use it before it is considered fully stabilized, or try and backport the patch to your 2.6.4. ---------------------------------------------------------------------- daveinhull · 2015-03-06 08:10 Hi Can anyone give me an update? Thanks ---------------------------------------------------------------------- goodname · 2015-03-06 17:40 FPC 3.0 has not been released yet. It does contain the patch. If you don't want to go through compiling 3.0 yourself the web site http://www.getlazarus.org has been providing nightly SVN builds. It may just be Lazarus builds and not fpc builds so you will have to check to see what is there. ---------------------------------------------------------------------- jamhitz · 2015-03-17 07:15 If memory serves,  the use of the DataSource to propagate Master- Detail setups was always an issue even in the days of Delphi 6.  I've learnt never to rely on that implementation.  I instead use the AfterScroll event to manually propagate my Master-Detail setups. Something like this: Code: [Select]TForm1 = class(TForm)         SQLQuery1: TSQLQuery;         SQLQuery2: TSQLQuery;         procedure SQLQuery1AfterOpen(DataSet: TDataSet);         procedure SQLQuery1AfterScroll(DataSet: TDataSet);     private         isReady: Boolean;     end; var     Form1: TForm1; implementation procedure TForm1.SQLQuery1AfterScroll(DataSet: TDataSet); begin     if SQLQuery2.Active then SQLQuery2.Close;     if isReady then     begin         SQLQuery2.ParamByName('MASTER_ID').AsInteger := SQLQuery1.FieldByName('ID').AsInteger;         SQLQuery2.Open;     end; end; procedure TForm1.SQLQuery1AfterOpen(DataSet: TDataSet); begin     isReady := true;     SQLQuery1AfterScroll(DataSet); end; Have you considered this approach? ---------------------------------------------------------------------- daveinhull · 2015-04-10 11:51 Hi goodname, jamhitz, Thanks for the replies. goodname, can you point me in the right direction to do a backport the patch? jamhitz, thanks for the idea which I'll look at if I can't get the backport working Many thanks Dave ---------------------------------------------------------------------- goodname · 2015-04-10 16:20 http://wiki.freepascal.org/Installing_Lazarus or http://www.getlazarus.org/setup/ ---------------------------------------------------------------------- daveinhull · 2015-04-13 18:34 Hi all, Thanks goodname, got the setup and install. The database scrolling problem seems to be fixed, but now I've got another (small) problem. I use TSQLQuery but now I'm getting an : TSQLDBFieldDefs against its uses. Its probably something I've not done, or done as part of the nightly build install. Any help would be much appreciated. Thanks Dave