Hi. I have an application that has been working fine for at least 2 years. Around January of this year, some of our tech people made a bunch of changes in the virtual infrastructure, physical networking, etc. to the servers hosting our ASP.NET apps. After these changes (of which there were far too many to be able to isolate), I am now having problems with one of my apps
The app uses a ReportViewer control to display a report. It works most of the time, but sporadically, and such that I can't reproduce it, the users will get an error "A data source instance has not been supplied for the data source", and the report will not display. I am trying to figure out how to either 1) find out from Windows error logs or some other method what is causing this to happen, or 2) be able to work around it so that the user can try to re-run the report if it happens. Here is a sample of the code I am using. I have added the Try...Catch block and the display of a "try again" button to let them try the report again. This error-handling change has not been pushed out yet, so I am not sure if this will help, but I hope so, at least so they can try again. The report they complain about not working the most is the one handled by the report type "KeyReturn" in the code.
Please advise if there is a particular Windows error log I can try to look at to see what is causing this problem, or if there is some other way that I don't know about that I can use to prevent this from happening. Thank you.
Protected Sub PrintReport() Dim BadCall As Boolean = False Try rvReportViewer.LocalReport.DataSources.Clear() Select Case lblRepType.Text Case "KeyReceipt" rvReportViewer.LocalReport.ReportPath = "Reports\KeyReceipt.rdlc" Dim reportParameters(0) As ReportParameter reportParameters(0) = New ReportParameter("Building", lblBuildingName.Text) rvReportViewer.LocalReport.SetParameters(reportParameters) ObjectDSKeyReceipt.SelectParameters("CustID").DefaultValue = lblCustID.Text ObjectDSKeyReceipt.SelectParameters("Building").DefaultValue = lblBuildingCode.Text ObjectDSKeyReceipt.SelectParameters("incident").DefaultValue = lblRepOptions.Text ObjectDSKeyReceipt.SelectParameters("RepDate").DefaultValue = lblRepOptions2.Text '' ObjectDSKeyReceiptSubKeycode.SelectParameters("CustID").DefaultValue = lblCustID.Text ObjectDSKeyReceiptSubKeycode.SelectParameters("Building").DefaultValue = lblBuildingCode.Text ObjectDSKeyReceiptSubKeycode.SelectParameters("incident").DefaultValue = lblRepOptions.Text ObjectDSKeyReceiptSubKeycode.SelectParameters("RepDate").DefaultValue = lblRepOptions2.Text '' ObjectDSKeyReceiptSubCurrentCharge.SelectParameters("CustID").DefaultValue = lblCustID.Text ObjectDSKeyReceiptSubCurrentCharge.SelectParameters("Building").DefaultValue = lblBuildingCode.Text ObjectDSKeyReceiptSubCurrentCharge.SelectParameters("incident").DefaultValue = lblRepOptions.Text ObjectDSKeyReceiptSubCurrentCharge.SelectParameters("RepDate").DefaultValue = lblRepOptions2.Text rvReportViewer.LocalReport.DataSources.Add(New ReportDataSource("DataSetKeyReceipt", "ObjectDSKeyReceipt")) AddHandler rvReportViewer.LocalReport.SubreportProcessing, AddressOf SetKeyReceiptSubDataSource Case "KeyReturn" rvReportViewer.LocalReport.ReportPath = "Reports\KeyReturn.rdlc" Dim reportParameters(0) As ReportParameter reportParameters(0) = New ReportParameter("Building", lblBuildingName.Text & " Key Receipt") rvReportViewer.LocalReport.SetParameters(reportParameters) ObjectDSKeyReturn.SelectParameters("CustID").DefaultValue = lblCustID.Text ObjectDSKeyReturn.SelectParameters("Building").DefaultValue = lblBuildingCode.Text ObjectDSKeyReturn.SelectParameters("incident").DefaultValue = lblRepOptions.Text ObjectDSKeyReturn.SelectParameters("RepDate").DefaultValue = lblRepOptions2.Text '' ObjectDSKeyReturnSubCharges.SelectParameters("CustID").DefaultValue = lblCustID.Text ObjectDSKeyReturnSubCharges.SelectParameters("Building").DefaultValue = lblBuildingCode.Text ObjectDSKeyReturnSubCharges.SelectParameters("incident").DefaultValue = lblRepOptions.Text ObjectDSKeyReturnSubCharges.SelectParameters("RepDate").DefaultValue = lblRepOptions2.Text rvReportViewer.LocalReport.DataSources.Add(New ReportDataSource("DataSetKeyReturn", "ObjectDSKeyReturn")) AddHandler rvReportViewer.LocalReport.SubreportProcessing, AddressOf SetKeyReturnSubDataSource Case "LateKeyNotification" rvReportViewer.LocalReport.ReportPath = "Reports\LateKey.rdlc" Dim reportParameters(0) As ReportParameter reportParameters(0) = New ReportParameter("Building", lblBuildingName.Text) rvReportViewer.LocalReport.SetParameters(reportParameters) ObjectDSLateKey.SelectParameters("CustID").DefaultValue = lblCustID.Text ObjectDSLateKey.SelectParameters("Building").DefaultValue = lblBuildingCode.Text ObjectDSLateKey.SelectParameters("incident").DefaultValue = lblRepOptions.Text rvReportViewer.LocalReport.DataSources.Add(New ReportDataSource("DataSetLateKey", "ObjectDSLateKey")) Case "KeysOut" rvReportViewer.LocalReport.ReportPath = "Reports\KeysOut.rdlc" Dim reportParameters(0) As ReportParameter reportParameters(0) = New ReportParameter("BuildingName", lblBuildingName.Text) rvReportViewer.LocalReport.SetParameters(reportParameters) ObjectDSKeysOut.SelectParameters("Building").DefaultValue = lblBuildingCode.Text rvReportViewer.LocalReport.DataSources.Add(New ReportDataSource("DataSetKeysOut", "ObjectDSKeysOut")) Case Else BadCall = True End Select If Not BadCall Then rvReportViewer.ProcessingMode = ProcessingMode.Local rvReportViewer.Visible = True rvReportViewer.LocalReport.Refresh() Else divReports.Visible = False divButtons.Visible = True lblError.Text = "There was an error calling this page to print a report. Please close the window/tab. Report requested was " & lblRepType.Text btnReprintReport.Visible = False End If Catch ex As Exception divReports.Visible = False divButtons.Visible = True lblError.Text = "There was an error calling this page to print a report. Please close the window/tab, or try the report again. " &"Report requested was '" & lblRepType.Text & "'. The error reported was: " & ex.Message btnReprintReport.Visible = True End Try End Sub Protected Sub SetKeyReceiptSubDataSource(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs) e.DataSources.Add(New ReportDataSource("DataSetKeyReceipt_SubReportKeycode", "ObjectDSKeyReceiptSubKeycode")) e.DataSources.Add(New ReportDataSource("DataSetKeyReceipt_SubReportCurrentCharge", "ObjectDSKeyReceiptSubCurrentCharge")) e.DataSources.Add(New ReportDataSource("DataSetKeyReceipt_SubReportRecoreCharges", "ObjectDSKeyReceiptSubRecoreCharges")) End Sub Protected Sub SetKeyReturnSubDataSource(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs) e.DataSources.Add(New ReportDataSource("DataSetKeyReturn_SubReportCharges", "ObjectDSKeyReturnSubCharges")) End Sub