Hello I am just trying to get my head round reporting in VB.NET.
The report view preview is working fine so it doesn't appear to be a problem with the report itself but the render as pdf is giving "Error occurred during local report processing", inner exception is giving "Error occurred during report processing"
I'm obviously missing something but can't see what. Be grateful if anybody could help shed any light on this please.
Private Sub ExportToPDFToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExportToPDFToolStripMenuItem1.Click
Try
Dim viewer As New Microsoft.Reporting.WinForms.ReportViewer
Dim report = New Microsoft.Reporting.WinForms.LocalReport
viewer.LocalReport.ReportEmbeddedResource = "ECUWMS.10day.rdlc"
viewer.ProcessingMode = ProcessingMode.Local
Dim rpJob As New ReportParameter
rpJob.Name = "JobNo"
rpJob.Values.Add("0000030")
viewer.LocalReport.SetParameters(New ReportParameter() {rpJob})
viewer.RefreshReport()
Dim reportinfo As Byte() = viewer.LocalReport.Render("PDF") ' --> Errors here.
Dim SFD As New SaveFileDialog
SFD.Filter = "PDF Files(*.PDF) | *.pdf"
If SFD.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim newfile As New FileStream(SFD.FileName, FileMode.Create, FileAccess.Write)
newfile.Write(reportinfo, 0, reportinfo.Length)
newfile.Close()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK)
End Try
End Sub
As 'suggested' in the
ex.InnerException.InnerException.Message
you need to provide aReportDataSource
nameddsJobs
to yourLocalReport
.