Jim Buckley Barret
Jim Buckley Barret

Reputation: 330

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

Upvotes: 0

Views: 8889

Answers (2)

Ccorock
Ccorock

Reputation: 892

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.

Upvotes: 0

Trevor
Trevor

Reputation: 8004

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.

Upvotes: 0

Related Questions