M
Madison
Hi all,
I'm using VS2010 web application. I'm trying to use subreport with
reportviewer. The report is working with my machine, it returns the main and
sub report. But when moved to web-server, the main report display, not the
subreport and no error indicate. I did something like this with VS2005, I did
not have any problems. Here is my coding:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim ReportViewer1 As New ReportViewer
Dim rptDataSourceMain As New ReportDataSource("dsSRC",
GetDataSet("p_SRC_completed_main").Tables(0))
With ReportViewer1
.ProcessingMode = ProcessingMode.Local
.AsyncRendering = False
.LocalReport.ReportPath = "content\SRC.rdlc"
.LocalReport.DataSources.Clear()
.LocalReport.DataSources.Add(rptDataSourceMain)
End With
' HANDLE the sub-report
AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf
SetSubDataSource
ReportViewer1.LocalReport.Refresh()
Try
Dim deviceInfo As String = "<DeviceInfo>" & _
"<OutputFormat>PDF</OutputFormat>" & _
"<PageWidth>8.5in</PageWidth>" & _
"<PageHeight>11in</PageHeight>" & _
"<MarginTop>0.5in</MarginTop>" & _
"<MarginLeft>0.75in</MarginLeft>" & _
"<MarginRight>0.4in</MarginRight>" & _
"<MarginBottom>0in</MarginBottom>" & _
"</DeviceInfo>"
Dim formatPDF As Byte() =
ReportViewer1.LocalReport.Render("PDF", deviceInfo, Nothing, Nothing,
Nothing, Nothing, Nothing)
Response.Clear()
Response.ContentType = ""
Response.AddHeader("content-disposition", "attachment;
filename=SRC.pdf")
Response.BinaryWrite(formatPDF)
Response.End()
Catch ex As Exception
Response.Write("ERROR:" & ex.ToString)
End Try
End Sub
'
=========================================================================
' Handle subreport call dataset
'
=========================================================================
Protected Sub SetSubDataSource(ByVal sender As Object, ByVal e As
SubreportProcessingEventArgs)
e.DataSources.Add(New ReportDataSource("dsSRCsub",
GetDataSet("p_SRC_completed_sub").Tables(0)))
End Sub
'
=========================================================================
' Get the dataset to reportviewer (both main and sub) without
SQLdatasource
'
=========================================================================
Protected Function GetDataSet(ByVal spName As String) As DataSet
GetDataSet = Nothing
Dim cnnPath As String =
ConfigurationManager.ConnectionStrings("cnPath").ConnectionString
Dim cnn As New SqlConnection(cnnPath)
Dim cmd As New SqlCommand
Dim ds As New DataSet
Dim da As SqlDataAdapter
With cmd
.Connection = cnn
.CommandType = CommandType.StoredProcedure
.CommandText = spName
.Parameters.Add("@util_id", SqlDbType.Int).Value = 1990
End With
Try
cnn.Open()
da = New SqlDataAdapter(cmd)
da.Fill(ds)
GetDataSet = ds
Catch ex As Exception
Response.Write("ERROR: " & ex.ToString)
GetDataSet = Nothing
Finally
cmd.Dispose()
cnn.Close()
cnn.Dispose()
End Try
End Function
Any solutions for this problems in VS2010.
Thanks.
I'm using VS2010 web application. I'm trying to use subreport with
reportviewer. The report is working with my machine, it returns the main and
sub report. But when moved to web-server, the main report display, not the
subreport and no error indicate. I did something like this with VS2005, I did
not have any problems. Here is my coding:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim ReportViewer1 As New ReportViewer
Dim rptDataSourceMain As New ReportDataSource("dsSRC",
GetDataSet("p_SRC_completed_main").Tables(0))
With ReportViewer1
.ProcessingMode = ProcessingMode.Local
.AsyncRendering = False
.LocalReport.ReportPath = "content\SRC.rdlc"
.LocalReport.DataSources.Clear()
.LocalReport.DataSources.Add(rptDataSourceMain)
End With
' HANDLE the sub-report
AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf
SetSubDataSource
ReportViewer1.LocalReport.Refresh()
Try
Dim deviceInfo As String = "<DeviceInfo>" & _
"<OutputFormat>PDF</OutputFormat>" & _
"<PageWidth>8.5in</PageWidth>" & _
"<PageHeight>11in</PageHeight>" & _
"<MarginTop>0.5in</MarginTop>" & _
"<MarginLeft>0.75in</MarginLeft>" & _
"<MarginRight>0.4in</MarginRight>" & _
"<MarginBottom>0in</MarginBottom>" & _
"</DeviceInfo>"
Dim formatPDF As Byte() =
ReportViewer1.LocalReport.Render("PDF", deviceInfo, Nothing, Nothing,
Nothing, Nothing, Nothing)
Response.Clear()
Response.ContentType = ""
Response.AddHeader("content-disposition", "attachment;
filename=SRC.pdf")
Response.BinaryWrite(formatPDF)
Response.End()
Catch ex As Exception
Response.Write("ERROR:" & ex.ToString)
End Try
End Sub
'
=========================================================================
' Handle subreport call dataset
'
=========================================================================
Protected Sub SetSubDataSource(ByVal sender As Object, ByVal e As
SubreportProcessingEventArgs)
e.DataSources.Add(New ReportDataSource("dsSRCsub",
GetDataSet("p_SRC_completed_sub").Tables(0)))
End Sub
'
=========================================================================
' Get the dataset to reportviewer (both main and sub) without
SQLdatasource
'
=========================================================================
Protected Function GetDataSet(ByVal spName As String) As DataSet
GetDataSet = Nothing
Dim cnnPath As String =
ConfigurationManager.ConnectionStrings("cnPath").ConnectionString
Dim cnn As New SqlConnection(cnnPath)
Dim cmd As New SqlCommand
Dim ds As New DataSet
Dim da As SqlDataAdapter
With cmd
.Connection = cnn
.CommandType = CommandType.StoredProcedure
.CommandText = spName
.Parameters.Add("@util_id", SqlDbType.Int).Value = 1990
End With
Try
cnn.Open()
da = New SqlDataAdapter(cmd)
da.Fill(ds)
GetDataSet = ds
Catch ex As Exception
Response.Write("ERROR: " & ex.ToString)
GetDataSet = Nothing
Finally
cmd.Dispose()
cnn.Close()
cnn.Dispose()
End Try
End Function
Any solutions for this problems in VS2010.
Thanks.