FR6 not handling dataset' events the same as FR5, causing problems.
Hello,
I've just had some reports from users that since changing to FR6 some of my reports are showing incorrect data.
Looking into it, what I can see is that the "OnFirst", "OnNext", "OnPrior" events from a TfrxDBDataset are being called, but the linked dataset cursor is apparently not being changed between records.
For instance, I have a master-detail-subdetail report. For speed reasons, I load the whole resultset into memory tables. This tables are linked each one to a TfrxDBDataset. using the OnFirst, OnNext, OnPrior events I set a filter into the corresponding detail dataset, using the value of the parent record.
So, for the Master dataset, corresponding to table A, on the OnFirst/... events I set a filter on the detail dataset, table B, using tableA->FieldByName("Id"). On B, I set a filter on it's detail dataset, table C, using tableB->Id. And so on.
The problem is that even if the events are being called correctly, the corresponding value on the linked dataset is not changed, as if the linked dataset was not being advanced. The values printed on the report are incorrect (as the details/subdetails don't correspond to the correct parent).
Building this with FR5 works fine (as it was working before changing FR version)
Is there something changed between FR5 and FR6 that needs to be addressed for this to work again?
I've tried this with FR 6.0.10 and FR 6.1 with the same results.
I've just had some reports from users that since changing to FR6 some of my reports are showing incorrect data.
Looking into it, what I can see is that the "OnFirst", "OnNext", "OnPrior" events from a TfrxDBDataset are being called, but the linked dataset cursor is apparently not being changed between records.
For instance, I have a master-detail-subdetail report. For speed reasons, I load the whole resultset into memory tables. This tables are linked each one to a TfrxDBDataset. using the OnFirst, OnNext, OnPrior events I set a filter into the corresponding detail dataset, using the value of the parent record.
So, for the Master dataset, corresponding to table A, on the OnFirst/... events I set a filter on the detail dataset, table B, using tableA->FieldByName("Id"). On B, I set a filter on it's detail dataset, table C, using tableB->Id. And so on.
The problem is that even if the events are being called correctly, the corresponding value on the linked dataset is not changed, as if the linked dataset was not being advanced. The values printed on the report are incorrect (as the details/subdetails don't correspond to the correct parent).
Building this with FR5 works fine (as it was working before changing FR version)
Is there something changed between FR5 and FR6 that needs to be addressed for this to work again?
I've tried this with FR 6.0.10 and FR 6.1 with the same results.
Comments
<strike>Maybe the culprit is this fix: "- Fixed issue when used RangeEnd = reCount to limit records of the dataset" in version 5.6.12?</strike> I thought the problem was that, but I reinstalled 5.6.12 and this still happens. I moved back to the previous installer I had, 5.6.8, and with that version this works fine.
When running with the BPLs of version 5.6.8 the reports are generated correctly. When using 5.6.12+ then I get the errors. This is with *exactly* the same executable, the only thing that changes is the runtime packages of FR.
I added some logging to the OnFirst/OnNext events to try to see what's happening and I see the following:
For the correct run, this is the log:
For a run with the latest versions, I get the following log:
As you can see, the Next doesn't really appear to have moved the cursor in the dataset until the last call (the one that gets to Eof, I assume). In the correct run the Next has correctly changed the current record. This happens for the two details here: RPautas and RDiasPauta.
Any ideas on how to solve this? Is it a bug, or some setting that needs to be changed from 5.6.8+ ?
The previous version, which works, is:
I'm guessing that the problem comes because the inherited Next call is setting the Eof flag, then the new validation occurs which ends the procedure without calling the Next on the FDS. In the case I'm checking it's easy to see the problem as there are only 2 records, probably if there were more records only the last one would be repeated.
As I don't know why the code was changed as it was, I don't know if moving the FDS.Next before the inherited Next in the new code is the correct solution or if it is like this for some particular reason. Anyone from FR care to comment?
Have you raised a Ticket with Support? I find they are pretty quick to respond.
https://support.fast-report.com
Cheers, Paul
I haven't. I didn't know if it was indeed a bug or just something I needed to change in the configuration or settings of the report. Looking at the code I do believe now it is a bug, but I wonder why nobody else has reported it? Anyway, I changed the code in FR6, rebuilt and now my reports are working fine again. I will create a ticket anyway to let FR know directly and maybe they can confirm if the solution is correct or something else is going on.
Thanks