An error occurred during local report processing


S

smkkaleem

I am stuck with the error I have posted above in the question title

I am developing ASP.NET 2.0 web site and I have added a new rdlc file
to my project by using the following process:

-Right clicking my project in the Solutions explorer
-Selecting Add New Item
-Selecting Report.rdlc template
-Renaming it to Main.Rdlc and then clicking OK.

As you know that rdlc file is a local report file that runs on the
client side (no reporting server needed in this case). While I add this
file, a wizard appears that prompts me the connection string from my
Web Config file and allows me to select the existing stored procedure I
want to use to display the data to my report. I can see the output
columns of the stored procedure in the left pane and the report
designer in the right pane. I have done a drag and drop of those
columns from the left pane to the report designer of main.rdlc file in
the right pane and saved the main.rdlc file. Now I want to render this
main.rdlc file programatically. Following is the code I am using:

Imports System.Web.Configuration
Imports System.Security.Principal
Imports System.data.DataSet
Imports System.data.SqlClient
Imports System.IO
Imports System.Xml
Imports Microsoft.Reporting.WebForms
Imports System.Collections.Generic
Imports System.Text
Imports System.Drawing.Imaging
Imports System.Drawing.Printing

Protected Sub btnReport_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnReport.Click

Dim warnings As Microsoft.Reporting.WebForms.Warning() =
Nothing
Dim streamids As String() = Nothing
Dim mimeType As String = Nothing
Dim encoding As String = Nothing
Dim extension As String = Nothing
Dim lr As New LocalReport

lr.ReportPath = "C:\Projects\Marketing Initiatives\Main.rdlc"

lr.DataSources.Add(New ReportDataSource("FSI", FSIList))
'FSIList is a datatable thta I have previously returned in another
method

Export(lr)

m_currentPageIndex = 0
PrintReport()

End Sub

Private Sub Export(ByVal report As LocalReport)
Dim deviceInfo As String = _
"<DeviceInfo>" + _
" <OutputFormat>EMF</OutputFormat>" + _
" <PageWidth>8.5in</PageWidth>" + _
" <PageHeight>11in</PageHeight>" + _
" <MarginTop>0.25in</MarginTop>" + _
" <MarginLeft>0.25in</MarginLeft>" + _
" <MarginRight>0.25in</MarginRight>" + _
" <MarginBottom>0.25in</MarginBottom>" + _
"</DeviceInfo>"
Dim warnings() As Warning = Nothing
m_streams = New List(Of Stream)()

Try
report.Render("Image", deviceInfo, AddressOf CreateStream,
_
warnings)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try

Dim stream As Stream
For Each stream In m_streams
stream.Position = 0
Next
End Sub

Private Function CreateStream(ByVal name As String, _
ByVal fileNameExtension As String, _
ByVal encoding As Encoding, ByVal mimeType As String, _
ByVal willSeek As Boolean) As Stream
Dim stream As Stream = _
New FileStream("..\..\" + _
name + "." + fileNameExtension, FileMode.Create)
m_streams.Add(stream)
Return stream
End Function

Private Sub PrintReport()
Const printerName As String = _
"Microsoft Office Document Image Writer"

If m_streams Is Nothing Or m_streams.Count = 0 Then
Return
End If

Dim printDoc As New PrintDocument()
printDoc.PrinterSettings.PrinterName = printerName
If Not printDoc.PrinterSettings.IsValid Then
Dim msg As String = String.Format( _
"Can't find printer ""{0}"".", printerName)
Console.WriteLine(msg)
Return
End If
AddHandler printDoc.PrintPage, AddressOf PrintPage
printDoc.Print()
End Sub

Private Sub PrintPage(ByVal sender As Object, _
ByVal ev As PrintPageEventArgs)
Dim pageImage As New Metafile(m_streams(m_currentPageIndex))
ev.Graphics.DrawImage(pageImage, ev.PageBounds)

m_currentPageIndex += 1
ev.HasMorePages = (m_currentPageIndex < m_streams.Count)
End Sub


The problem is that in the Export sub above, I get the following error
method in the following line of the code:

Try
report.Render("Image", deviceInfo, AddressOf CreateStream,
_
warnings)
Catch ex As Exception
Console.WriteLine(ex.Message)
'''Error ex.Message = "An error occurred during local report
processing"
End Try

Does anyone has a clue what am I doing wrong in the code above...
I will really appreciate for a help,

Thanks a lot
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top