Rare multi-subreport error: Invalid attempt to read when no data is present

  • jyoder 5 months, 1 week ago

    I’m hoping you can help us with an issue that’s driving me crazy. We have a report with 8 subreports. Usually it runs fine, but once in a while for certain data it’ll throws an “Invalid attempt to read when no data is present” error. Here’s what I’ve done…

    I took someone’s data it did this to and I vastly simplified the report down to bare bones, but to where it’ll still give the error. So in the zipped file, you’ll find 4 reports — a main report with only 3 sub reports (which correspond in sequential order on those on the main report). You’ll also see the main report has a script where it passes parameters to the subreports.

    With most data we have, these run fine. But with certain data, it gives the error message above. What’s doubly odd, is if I move the 3rd subreport down about half an inch, then sometimes it won’t give the error. This makes no sense to me. Can you tell us what the issue is and how can we get around it?

    Attachments:
    1. Reports.zip
  • 597p
    Reema597p 5 months, 1 week ago

    Hello,

    As you have shared that the error messages appear with certain specific data, we request you to kindly share the xml data with which the reports are bound or some test/dummy data that would help us to reproduce the issue at our end and assist you appropriately.
    Just in case if you haven’t, please test the case once with our latest release and share your observations :

    http://activereports.grapecity.com/downloads/

    Regards,
    Reema

  • jyoder 5 months ago

    I can’t come up with the correct XML data and we really need this fixed. If it helps, here’s the full error message, which I hope can enable you to determine the issue…

    System.InvalidOperationException: Invalid attempt to read when no data is present. at System.Data.SqlClient.SqlDataReader.GetValue(Int32 i) at GrapeCity.ActiveReports.Data.DataLayer.#B4c(Int32 cookie) at GrapeCity.ActiveReports.Data.Field.get_Value() at #BYA.#ypb.#7xb(Section section) at #sxA.#vqb.#4YA(Object parentReport, Single left, Single top, Single right, Single bottom) at GrapeCity.ActiveReports.SectionReportModel.Section.#yBb(SectionReport parentReport, #tqb rData) at #sxA.#mqb.#NDb(Int32 pieceIndex) at #sxA.#mqb.#LDb() at #sxA.#mqb.#SDb(Section section, Int32 insPos) at #sxA.#vqb.#vEb() at #sxA.#vqb.#bZA(Page newPage, Single left, Single top, Single right, Single bottom, UInt32 flags, UInt32& status) at GrapeCity.ActiveReports.SectionReport.#4yb() at GrapeCity.ActiveReports.SectionReport.Run(Boolean syncDocument)

    If I print this report with 2 certain employees, we get this error. However, if I print only 1 of either of them, it works fine, so apparently is has to do with going to the next page, as the report doesn’t render past the 1st employee, but only shows “1/1+” in the page display, rather than “1/2″ as it should.

    The issue seems to occur when there’s too much data in the 2nd subreport — the one labeled “Employee Checks-Deduction Subreport”. When it has 15 rows (which I tested by altering its query to “select top 15″) it works fine. But with only one more row (“select top 16″) then it creates this error.

  • 185p
    AbdiasM185p 5 months ago

    Since the issue is specific to data as you’ve mentioned, it’s really difficult to comment on the cause or provide a solution without being able to reproduce it. It’ll be really helpful if you could also provide the xml file being used as the datasource for the reports so that we can test it at our end as well.
    Also, can you confirm the AR version you’re using?

  • jyoder 4 months, 4 weeks ago

    I’m trying to get a main report with 3 subreports that works with XML data, but I’m having problems making it come together. Do you have a concrete example of this that I can download to understand better? The reports I have are 4 separate rpx files, with each having their own XML data file. But as I understand it, all the data needs to be in 1 main XML?

  • 185p
    AbdiasM185p 4 months, 3 weeks ago

    All data doesn’t necessarily have to be in one xml file; it can be in different xml files. However, it’s better to have all data in a single xml file for showing conditional data in sub-reports.
    I have attached a sample application with two reports (XmlReport.rpx & Customers.rpx). The XmlReport.rpx is the main report and Customers.rpx is the subreport. Both the reports have different xml files as DataSource. Please take a look.

    You could also refer to the following documentation link for more clarification on the use of xml datasource in subreports:

    http://arhelp.grapecity.com/webhelp/AR10/index.html#arWLKSubreportsWithXMLData.html

    Also, take a look at the Xml product sample installed with the product at: \Documents\GrapeCity Samples\ActiveReports 10\Section Reports\Data\XML, for better understanding of the Xml DataSource.

  • jyoder 4 months, 3 weeks ago

    I was able to get an XML duplicate to work and look the same as the one that queries SQL. However, it does NOT give the \”Invalid attempt to read when no data is present\” error but works fine.

    That\’s incredibly discouraging. However, given the full error message I posted above, the error does seem to stem from actually querying the data rather than an ActiveReport setting. (Though obviously some combo of ActiveReport settings is causing it as it queries the data.)

    Does this help you in determining the issue?

  • jyoder 4 months, 3 weeks ago

    Since XML didn’t work , I was able to make a dummy SQL DB and 4 ActiveReports to enable you to get this error. You’ll find all 5 files included in the zip file. (Of course, once you restore the SQL DB, you’ll need to change the username and password in the connection string of each rpx file to work with your SQL instance.)

    Really looking forward to learning what you find out.

    Attachments:
    1. SQL-Example.zip
  • 185p
    AbdiasM185p 4 months, 3 weeks ago

    Thanks a ton for the report files and the database backup. I could observe the error at my end as well after restoring the db. After much debugging I found that the error occurs because there is no data present in the ‘vprChecksLeavesSummary’ table and when AR attempts to retrieve data and doesn’t find anything, it throws the error.
    So I came up with two solutions:
    1. Add some data to the ‘vprChecksLeavesSummary’ table. The reports worked fine without any error once I added few records to the table.
    2. The second solution is to handle the NoData event of the three SubReports and cancel them. The NoData event is fired in case the report’s DataSource does not return any records.

    SectionReport subrpt1, subrpt2, subrpt3;
    
            private void Rpt_ReportStart(object sender, EventArgs e)
            {
                subrpt1 = new SectionReport();
                XmlTextReader xtr1 = new XmlTextReader(“..\\..\\Reports\\Report_Sub_1.rpx”);
                subrpt1.LoadLayout(xtr1);
                subrpt1.NoData += Subrpt1_NoData;
                xtr1.Close();
    
                subrpt2 = new SectionReport();
                XmlTextReader xtr2 = new XmlTextReader(“..\\..\\Reports\\Report_Sub_2.rpx”);
                subrpt2.LoadLayout(xtr2);
                subrpt2.NoData += Subrpt2_NoData;
                xtr2.Close();
    
                subrpt3 = new SectionReport();
                XmlTextReader xtr3 = new XmlTextReader(“..\\..\\Reports\\Report_Sub_3.rpx”);
                subrpt3.LoadLayout(xtr3);
                subrpt3.NoData += Subrpt3_NoData;
                xtr3.Close();
    
            }
    
            private void Subrpt3_NoData(object sender, EventArgs e)
            {
                (sender as SectionReport).Cancel();
            }
    
            private void Subrpt2_NoData(object sender, EventArgs e)
            {
                (sender as SectionReport).Cancel();
            }
    
            private void Subrpt1_NoData(object sender, EventArgs e)
            {
                (sender as SectionReport).Cancel();
            }

    I have attached an application with the above implementation and it works fine.

    Hope it helps

  • jyoder 4 months, 3 weeks ago

    So glad you can replicate it now! We can’t simply add data as it varies for customers, and I have questions about your possible second solution.

    Even though the error is triggered from having no data in the 1st subreport, if you simply delete 4 rows from the table used in the 2nd subreport, as can be done via this query…

    delete from vprChecksDeductions
    where vprChecksDeductions_CheckKey = 34473
    and vprChecksDeductions_DeductionSort = ‘T’

    … then the report works fine. Or instead, if you simply move the subreports around a bit (as you can see in the slightly modified main report I attached) it also works fine. (We also have 100′s of other reports with subreports that sometimes have no data and they never get this error.)

    All this seems to indicate there’s a minor bug in ActiveReports that triggers based off a certain layout and/or data output. Would you agree?

  • 185p
    AbdiasM185p 4 months, 3 weeks ago

    Thanks for the modified report file. I agree it could be a bug. Let me get in touch with the dev team regarding this and get back to you. The tracking Id is 220064.

    Abdias

  • jyoder 4 months, 2 weeks ago

    Any word yet? Can I use the tracking ID of 220064 you gave to somehow keep tabs on it?

  • 185p
    AbdiasM185p 4 months, 2 weeks ago

    The development team is working on a fix for this issue. I’ll let you know as soon as it is fixed.

  • jyoder 4 months, 1 week ago

    When this is fixed, will it be for Version 9, or will we need to upgrade to version 11?

  • 185p
    AbdiasM185p 4 months, 1 week ago

    Since the final service pack of version 9 was released 9 months ago, it’ll be fixed in ActiveReports 10 SP3 and later releases (including version 11).

Viewing 15 posts - 1 through 15 (of 24 total)

You must be logged in to reply to this topic.