FetchData is raised even if there is no data to display


11-08-2005, 2:48 PM
Hi,

we are binding a report to a IDataReader (ADO.NET ExecuteReader done on an SQL*Server 2000 DB).

The report works fine when the reader contains rows.

When the repeater doesn't contain data (the SQL query returns 0 row), the FetchData is raised even if there is no data to display.

The help states the following:
Raised every time a new record is processed.

Is this behaviour by design or it is a bug?

Here are some technical specs:
-
AR 2.0 for .NET 2.0 (4.1.0.1127).
- Windows 2003
- IIS 6.0
- Net FrameWork 2.0 Beta 2
- C#
- ASP.NET

Mike Loubier

Re: FetchData is raised even if there is no data to display


11-08-2005, 3:01 PM

Mike,
        which version of Visual studio are you running on your machine? The build of arnet2 you have on your machine is not supposed to work with .Net framework 2.0 beta 2.


Rakesh Jani

Re: FetchData is raised even if there is no data to display


11-08-2005, 4:17 PM
We are working with Viual Studio 2005 Beta 2 (we are migrating next week to 2005 Final Version (Commercial Release) ).

We are using AR 2.0 version 4.1.0.1127 and VS 2005 Beta2 on a production server.  Everything works fine (except for the bug http://www.datadynamics.com/ShowPost.aspx?PostID=80735).

In our previous AR reports, we were using DataTable to bind data to the report.

From my point of view, DataReader seems to be easier to bind than other structure.  But, I ain't take the time to look at you code! Stick out tongue

If you can confirm such a bug is not present in the 2005 version of AR, we can wait for your Release Candidate or Final version.

Thanks.

Mike Loubier

Re: FetchData is raised even if there is no data to display


11-09-2005, 11:47 AM

Mike,

                   If it is an unbound report and if you are adding your field’s collection in the data initialize event. And setting your data reader in that event. The fetch data event would fire at least once . The Fetch Data has an EOF parameter indicating whether the Fetch Data event should fire. This parameter is not the same as the Record set’s EOF property and is defaulted to True. When working with bound reports (reports using a Data Control), the EOF parameter is automatically set by the report; however, when working with unbound reports this parameter needs to be controlled manually. And so if the data reader doesn’t have any records in it you can set it to true and it will not fire that event again. But it will fire at least one for unbound reports.


Rakesh Jani

Re: FetchData is raised even if there is no data to display


11-14-2005, 10:48 AM
After making some tests and reading the documentation, here is my conclusion:

I found the following text in the remark section the "FetchData" event:  "This event is used to set the values of custom unbound fields that were added in the DataInitialize event.".

In our scenarios, we always have custom fields created in the "DataInitialize" event.  Thus, this is not a bug of the report.

However, I did make tests with an empty DataInitialize event (no custom fields added) and also without the DataInitialize event.

What I found is that the FetchData event is always raised with the EOF property sets to True.  Our reports are always bound using the following pattern:

The data binding is made in a class outside the report class itself.  Thus, the code looks like this (this is not the actual code):

Report1 myReport = new Report1();
myReport.DataSource = myDataReader;
myReport.Run();

Can we consider this behaviour as a bug?  It looks like your engine implies that if we handle the "FetchData" event it will always be called at least once (even when there is no data and no custom fields).

Thanks



Re: FetchData is raised even if there is no data to display


11-18-2005, 12:20 PM
This isn't a bug - the report is designed in this fashion, and the Fetch Data event will always be called at least once in both bound and unbound situations.  The Fetch Data event is designed for you to manipulate the data in the Fields collection values prior to those values being bound to the controls on the section.  It's primarily used in unbound situations to add in data row by row, however I have seen people have a use for it in bound situations as well (the situation that comes to mind is calculated fields that need grouping in a page or group footer section - this would require valid Fields values that would need to be user-introduced in the code.

I hope this helps explain the use of Fetch Data a little better!

Michael Mason