'Report Viewer VB.NET

I'm just trying to figure out how to use Report Viewer in VB.NET.

The report has only one text box with the data element name set to ReportName.

The code is simple.

    Private Sub frmCalibrationPreviewReport_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    If _CalibrationReportID <> -1 Then
        With rvCalibrationReport
            .LocalReport.DataSources.Clear()
            .ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local
            Dim tmpData As DataTable = modDeclare.SelectSQL("SELECT ReportName FROM tblReportTypes")
            .LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("tmpData", tmpData))
        End With
    End If

    Me.rvCalibrationReport.RefreshReport()
End Sub

Nothing is appearing on the report, it should contain two records.

Where am I going wrong?

Jim



Solution 1:[1]

Here's a great article covering Report Viewer

I mention this link as it appears your new to this. I would recommend reading this first.

Solution 2:[2]

Try Changing

.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("tmpData", tmpData))

To

.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("tmpData", tmpData.defaultview))

I would also suggest looking at this question, very similar to yours...

Bind DataTable to RDLC and ReportViewer

The problem with this question is there are a lot of gears at work when using reporting in visual studio. The problem could also be in the report file itself (.RDLC) if the field is not referencing the data source correctly. With the limited amount of information all I could suggest is using a working template and slowly adding your desired elements one at a time.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Trevor
Solution 2 Community