我的程序上有一个reportviewer 控件。它一直在工作,然后我改变了一些与它无关的东西。我有这个代码,在我的程序中,这个代码和另一个代码之间的唯一区别是数据集。但是,这个没有填充reportviewer中的数据。数据在数据表中,但未显示在报告中。有任何想法吗?
这是我的代码:
'Shows Appropriate Batch Reports
Private Sub btnShowBatchReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowBatchReport.Click
Try
'Get Dates for reports
Dim todayDate As Date = Today
Dim weekDate As Date = Today.AddDays(-7)
Dim monthDate As Date = Today.AddMonths(-1)
Dim yearDate As Date = Today.AddYears(-1)
Dim name As String = My.Settings.Store_Name
'Assigning the report name object
Dim BatchReportName As New Generic.List(Of ReportParameter)
If rbBatchAll.Checked Then
Me.OVERALLINVENTORYTableAdapter.Fill(Me.POSDataSet.OVERALLINVENTORY)
BatchReportName.Add(New ReportParameter("ReportBatchName", "All Batches"))
ElseIf rbBatchMonth.Checked Then
Me.OVERALLINVENTORYTableAdapter.FillByBetweenDates(Me.POSDataSet.OVERALLINVENTORY, monthDate, todayDate)
BatchReportName.Add(New ReportParameter("ReportBatchName", "Past Month Batches " & monthDate & " to " & todayDate))
ElseIf rbBatchWeek.Checked Then
Me.OVERALLINVENTORYTableAdapter.FillByBetweenDates(Me.POSDataSet.OVERALLINVENTORY, weekDate, todayDate)
BatchReportName.Add(New ReportParameter("ReportBatchName", "Past Week Batches " & weekDate & " to " & todayDate))
ElseIf rbBatchYear.Checked Then
Me.OVERALLINVENTORYTableAdapter.FillByBetweenDates(Me.POSDataSet.OVERALLINVENTORY, yearDate, todayDate)
BatchReportName.Add(New ReportParameter("ReportBatchName", "Past Year Batches " & yearDate & " to " & todayDate))
Else
Me.OVERALLINVENTORYTableAdapter.FillByBetweenDates(Me.POSDataSet.OVERALLINVENTORY, dpBatchStartDate.Value, dpBatchEndDate.Value)
BatchReportName.Add(New ReportParameter("ReportBatchName", "Custom Batches between" & dpBatchStartDate.Value & " and " & dpBatchEndDate.Value))
End If
'Resets the Report Viewer
rvBatchOrders.Reset()
'Creates the ReportData Source Object
Dim BatchOrders = New Microsoft.Reporting.WinForms.ReportDataSource
'Assigns the DataSet to the object
BatchOrders.Name = "InventoryBatch"
'Assigns the binding source of the dataset
BatchOrders.Value = INVENTORYBindingSource
'Clears Previous Data source
Me.rvBatchOrders.LocalReport.DataSources.Clear()
'Add the new data source
Me.rvBatchOrders.LocalReport.DataSources.Add(BatchOrders)
'Embeds the new report in the report viewer
rvBatchOrders.LocalReport.ReportEmbeddedResource = "POS_System_V2.OrderBatches.rdlc"
'Sets the Report Name
rvBatchOrders.LocalReport.SetParameters(BatchReportName)
rvBatchOrders.SetDisplayMode(DisplayMode.PrintLayout)
rvBatchOrders.ZoomMode = ZoomMode.PageWidth
'Refreshs the report viewer with the new report
rvBatchOrders.Refresh()
rvBatchOrders.RefreshReport()