Я пытаюсь создать отчет. Но он показывает сообщение об ошибке «Произошла ошибка во время локальной обработки отчета. Значение не может быть нулевым. Имя параметра: значение». Я заметил, что ошибка возникает, когда вложенный отчет не возвращает нулевое значение, но если вложенный отчет не имеет значений, он возвращает указанное сообщение об ошибке. Пожалуйста, помогите мне
Вот мой код:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Report()
End If
End Sub
Private Sub Report()
Dim warnings As Warning() = Nothing
Dim streamids As String() = Nothing
Dim mimeType As String = Nothing
Dim encoding As String = Nothing
Dim extension As String = Nothing
ServicePointManager.ServerCertificateValidationCallback = _
New System.Net.Security.RemoteCertificateValidationCallback(AddressOf customCertValidation)
Me.ReportViewer1.LocalReport.DataSources.Clear()
Dim adapter As New HumanResourceSystem.DataReportTableAdapters.tblIPCRTableAdapter
Dim table As New DataReport.tblIPCRDataTable
adapter.Fill(table, Session("RefNo").ToString(), Convert.ToDateTime(Session("Start").ToString()), Convert.ToDateTime(Session("End").ToString()))
Dim adapter1 As New HumanResourceSystem.DataReportTableAdapters.TrainingTableAdapter
Dim table1 As New DataReport.TrainingDataTable
adapter1.Fill(table1, Session("RefNo").ToString(), Session("GetYear").ToString())
Dim adapter2 As New HumanResourceSystem.DataReportTableAdapters.tbladhocassignmentTableAdapter
Dim table2 As New DataReport.tbladhocassignmentDataTable
adapter2.Fill(table2, Session("RefNo").ToString(), Convert.ToDateTime(Session("Start").ToString()), Convert.ToDateTime(Session("End").ToString()))
Dim rp1 As ReportParameter = New ReportParameter("Start", Convert.ToDateTime(Session("Start").ToString()))
Dim rp2 As ReportParameter = New ReportParameter("End", Convert.ToDateTime(Session("End").ToString()))
Dim rp3 As ReportParameter = New ReportParameter("RefNo", Session("RefNo").ToString())
ReportViewer1.LocalReport.SetParameters(New ReportParameter() {rp1, rp2})
Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSet1", CType(table, DataTable)))
Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSet2", CType(table1, DataTable)))
Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSet3", CType(table2, DataTable)))
ReportViewer1.LocalReport.ReportPath = "DataSet_Report/Report4.rdlc"
ReportViewer1.LocalReport.EnableExternalImages = True
Me.ReportViewer1.DataBind()
AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf SubreportProcessing
End Sub
Private Sub SubreportProcessing(sender As Object, e As SubreportProcessingEventArgs)
Try
Dim dt As DataTable = New System.Data.DataTable()
Dim adp As New SqlDataAdapter("NewStore", con)
adp.SelectCommand.CommandType = CommandType.StoredProcedure
adp.SelectCommand.Parameters.AddWithValue("@RefNo", Session("RefNo").ToString())
adp.SelectCommand.Parameters.AddWithValue("@Start", Convert.ToDateTime(Session("Start").ToString()))
adp.SelectCommand.Parameters.AddWithValue("@End", Convert.ToDateTime(Session("End").ToString()))
adp.Fill(dt)
Dim dts As New ReportDataSource("DataSet1", dt)
e.DataSources.Add(dts)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
https://i.stack.imgur.com/4SQbO.png