Wednesday, February 24, 2010

Active Reports - Fetch Data Fires Twice?

The past couple of days have been spent tracking down a problem I was having with a subreport showing blank data for the last record, even though it should have data. Whatever was the last record was, whether I had a single record or I had three records, it was all whitespace!!

Of course, I tore the report apart and nearly my hair out. I took out code that may have been tripping me up, I changed my data, I walked away from the computer. I read and re-read the Grape City support forum site. Nothing seemed to be working. But I did notice when I would debug, the FetchData would fire twice for the last record.

Nothing ever clicked with me until today. I was reading the support forum again and they warn of eArgs.EOF all over the place. (Scott, if you are reading this. I believe I saw a post from you on this!) And sure enough that was my problem. For this report, I needed to wrap the FetchData event around an eArgs.EOF check. And viola, I HAVE DATA.

private void report_FetchData(object sender, ActiveReport.FetchEventArgs eArgs)
{
if (eArgs.EOF == false)
{
...code here!
}
}

Whether this is right or wrong, it works, so I'm happy!!

5 comments:

  1. I'm reading it :) Thanks for posting this information. I think this is something that should somehow be more clear, but it is difficult to change such behavior now and I'm not sure how to document this to make it more clear. Suggestions?

    ReplyDelete
  2. I read your entire post!! I am not sure how is it possible?

    computer programming

    ReplyDelete
  3. @Centennial College

    this was in a subreport. i did have the main report checking for the EOF, but did not think to do that in the subreport.

    ReplyDelete
  4. @blog(scott)

    as far as documentation goes, if it is included somewhere that would be great. although, i only refer to documentation when something doesn't work :)

    It is kind of like the 'if (Page.IsPostBack)' for an Page_Load event of an aspx page, I'm not sure where I learned to check for that condition, it is just something I remember to include for post backs.

    ReplyDelete
  5. Thanks for the feedback elle. I guess I need to use my blogger account and not the open ID for comments to avoid being named "blog" :)

    ReplyDelete