Question Error Rendering report with multiple parameters

scottrgeorge

New member
Joined
Feb 8, 2016
Messages
2
Programming Experience
Beginner
I am very new to coding and have a project I am trying to fix that was created by a person that no longer works with our company. Can anyone help me figure out why I am getting this LocalProcessingException Occurred error? Below is my code. It dies on Response.Buffer = True. All of my parameters have data in them. But it seems as though one of the report generation variables doesn't have data in them. I am assuming its one of these - format, devInfo, extension, encoding, mimeType, streamids, warnings. Any help would be great. I have tried a lot of the other suggestions on this site but to no avail. And as I said this is really the first code I've gotten into.

The stack trace is >
at Microsoft.Reporting.WebForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, PageCountMode pageCountMode, CreateAndRegisterStream createStreamCallback, Warning[]& warnings) at Microsoft.Reporting.WebForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, PageCountMode pageCountMode, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings) at Microsoft.Reporting.WebForms.LocalReport.Render(String format, String deviceInfo, PageCountMode pageCountMode, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings) at Microsoft.Reporting.WebForms.Report.Render(String format, String deviceInfo, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings) at ChargingRequest._Default.btnPrint_Click(Object sender, EventArgs e) in H:\Visual Studio 2010\ChargingRequest\ChargingRequest\ChargeReq.aspx.vb:line 301.

Line 301 in my aspx.vb file is
Response.Buffer = True

' report generation variables
Dim warnings As Warning() = Nothing
Dim streamids As String() = Nothing
Dim mimeType As String = ""
Dim encoding As String = ""
Dim format As String = "PDF"
Dim extension As String = ""
Dim devInfo As String = "<DeviceInfo><Toolbar>True</Toolbar></DeviceInfo>"
Dim bytes As Byte() = Nothing
Dim lr As New LocalReport

Dim leadsTable As DataTable = retrievePersons(caseNum.Text)
Dim supplTable As DataTable = CType(Session("personTable"), DataTable)
Dim personTable As DataTable = combinePersons(leadsTable, supplTable)

' if there is data ...
If personTable.Rows.Count > 0 Then

' assume the best ....
ctlNotice
.Visible = False
ctlNotice
.Text = ""

' retrieve the charges
'Dim chargesTable As DataTable = retrieveCharges(caseNum.Text)
Dim chargesTable As DataTable = CType(Session("chargeTable"), DataTable)
Dim employeeTable As DataTable = retrieveEmployee()
Session
("employeeTable") = employeeTable

' make sure there were charges added
If chargesTable.Rows.Count = 0 Then
ctlNotice
.Visible = True
ctlNotice
.Text = "There are no charges. Please add them first."
Else
lr
.ReportEmbeddedResource = "CRForm.rdlc"
lr
.DataSources.Add(New ReportDataSource("ACRDataSet_DataTable1", personTable))

' charges for the charge subreport
lr
.DataSources.Add(New ReportDataSource("Charges02_ChargesTable", chargesTable))

' employee specific information
lr
.DataSources.Add(New ReportDataSource("Employee2", employeeTable))

' add the datasource update to the subreport
AddHandler lr.SubreportProcessing, AddressOf SubreportProcessingEventHandler
lr
.SetParameters(myParam)
'deviceInfo = "<DeviceInfo><OutputFormat>PDF</OutputFormat></DeviceInfo>"

Try
bytes
= lr.Render(format, devInfo, extension, encoding, mimeType, streamids, warnings)
Response
.Buffer = True
Response
.Clear()
Response
.ContentType = mimeType
Response
.AddHeader("content-disposition", "attachment; filename=ChargingRequest_" + cleanCaseNum(caseNum.Text) + ".pdf")
Response
.BinaryWrite(bytes)
Response
.Flush()
Session
("localReport") = bytes
Catch exn As Exception
ctlNotice
.Text = "Call Support!. Can't create the report! " & exn.Message
ctlNotice
.Visible = True
End Try
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,291
Location
Norway
Programming Experience
10+
I have never used LocalReport, so there could be other problems here that I'm not aware of, but I've done some web lookups.

According to stacktrace it is the above line (lr.Render) that throws exception.

You should remove the Response.Buffer line, it is deprecated. If you need to turn off buffering use BufferOutput property, but the default value for this is True.

The devInfo is not correct, the Toolbar device setting is for rendering to html, look here for PDF Device Information Settings.

Another tip is that you can check InnerExceptions where there may be more information about the problems that occur.
 

scottrgeorge

New member
Joined
Feb 8, 2016
Messages
2
Programming Experience
Beginner
Thanks for the info. I did go into the inner exception and it mentioned my employee2 data set. I went into the data set to preview the data and it had an error about not finding the correct connection string in the web.config file. I fixed that and got it working. However it is still pointing to my employee2 data set even though I have valid data in it. Now for the inner exception it just says "Nothing". So I still think it has to do with the report variables where I DIM them and have them = Nothing. Not sure where the failure is occurring. Its driving me quite nuts.

Stack trace on the inner exception
at Microsoft.ReportingServices.OnDemandProcessing.RuntimeDataSet.RunDataSetQuery()
at Microsoft.ReportingServices.OnDemandProcessing.RuntimeDataSet.Process()
at Microsoft.ReportingServices.OnDemandProcessing.RuntimeDataSet.ProcessConcurrent(Object threadSet)
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,291
Location
Norway
Programming Experience
10+
Top Bottom