This is a migrated thread and some comments may be shown as answers.

Dataset created at runtime shows no rows on report

1 Answer 71 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 2
Bob asked on 05 Mar 2014, 11:39 PM
Hi there -

I am using VB 2010 with 2013 Q3 reporting to generate a quick app that creates a report from a dataset created at runtime.
I followed the "best practices" in creating the solution; my UI app that contains the report viewer and a second project that contain the reports.

I create a dataset, datatable and manually add rows.  I followed previous examples to assign the created dataset to the report, however when I view the report, no rows are displayed.

The datatable contains two columns named BinTextValue and BinBarcodeValue.  On the report, the text fields value property is =Fields.[BinTextValue] and =Fields.[BinBarcodeValue].

Below is the code I am using to generate the dataset and set the datasource to the report.  Please let me know what I am missing.

Thanks
Bob

    Private Sub printBinLabels()
        Dim rpt As New BarcodeReport
        Dim rDS As New Telerik.Reporting.ObjectDataSource
        rDS.DataSource = getBinLabels()
        rDS.DataMember = "BinLabels"

        ' Print the labels
        Dim report As New Report
        report.DataSource = rDS


        Dim reportSource As New InstanceReportSource
        reportSource.ReportDocument = report
        rpt.ReportViewer1.ReportSource = reportSource
        rpt.ReportViewer1.RefreshReport()

        rpt.ShowDialog()
    End Sub

    Private Function getBinLabels() As DataSet
        Dim ds As New DataSet
        ds.DataSetName = "BarCodeLabels"

        Dim dt As New DataTable("BinLabels")
        dt.Columns.Add("BinTextValue", GetType(String))
        dt.Columns.Add("BinBarcodeValue", GetType(String))

        For Each line In BinNumbersTextBox.Text.Split(CChar(vbCrLf))
            If line.Trim.Length > 0 Then
                dt.Rows.Add(line.ToString, line.Replace("-", ""))
            End If
        Next

        ds.Tables.Add(dt)

        Return ds
    End Function

1 Answer, 1 is accepted

Sort by
0
Bob
Top achievements
Rank 2
answered on 06 Mar 2014, 03:39 PM
Nevermine.  A little sleep and fresh eyes, I managed to figure it out.
While looking through various examples, I typed in exactly what they suggested.  When I created a new instance of the "report", I actually used report:  reportSource.ReportDocument = report

The correct syntax is: reportSource.ReportDocument = {the class name of the actual report}.

It all works fine now.
Tags
General Discussions
Asked by
Bob
Top achievements
Rank 2
Answers by
Bob
Top achievements
Rank 2
Share this question
or