Reportviewer不填写数据

时间:2012-12-10 04:34:35

标签: vb.net report-viewer2010

我的程序有一个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()

1 个答案:

答案 0 :(得分:0)

我弄明白了这个问题。这很有趣,我试着解决这个问题3个小时。一旦我把它放在堆栈溢出,我立即发现问题。

问题

 BatchOrders.Value = INVENTORYBindingSource

答案:

 BatchOrders.Value = OVERALLINVENTORYBindingSource

我的绑定源错误。