KSUF
asked on
Using ASP and ssrs 2008 report execution service
The following code is not sending parameters to the report which resides on a report server.
Sub RenderReport()
'Private wsre As New finreporting.ReportExecuti onService( )
wsrs = New finreporting.ReportingServ ice2005()
wsre = New finreporting.ReportExecuti onService( )
wsre.Credentials = System.Net.CredentialCache .DefaultCr edentials
wsre.Url = "http://finreporting:8080/reportserver/ReportExecution2005.asmx?wsdl"
wsrs.Credentials = System.Net.CredentialCache .DefaultCr edentials
wsrs.Url = "http://finerporting:8080/reportserver/ReportService2005.asmx?wsdl"
'Render Arguments
Dim format As String = Nothing
Dim devInfo As String = "<DeviceInfo><Toolbar>Fals e</Toolbar ></DeviceI nfo>"
Dim extension As String = Nothing
Dim mimeType As String = Nothing
Dim encoding As String = "en-us"
Dim warnings As finreporting.Warning() = Nothing
Dim streamIDs As String() = Nothing
If rbPDF.Checked = True Then
reportfilepath = "/DonorRelations/FundConta ctsAndFina ncialsPDF"
format = "PDF"
extension = "PDF"
mimeType = "application/pdf"
filestreamfilepath = "c:\inetpub\wwwroot\Schola rshipConta ctsAndFina ncials\app files\Fund ReportPDF. pdf"
fileattachmentname = "attachment;filename=FundR eportPDF.p df"
Else
reportfilepath = "/DonorRelations/FundConta ctsAndFina ncials"
format = "Excel"
extension = "xls"
mimeType = "application/excel"
filestreamfilepath = "c:\inetpub\wwwroot\Schola rshipConta ctsAndFina ncials\app files\Fund ReportExce l.pdf"
fileattachmentname = "attachment;filename=FundR eportExcel .pdf"
End If
' Prepare report parameter.
Dim parameters(4) As finreporting.ParameterValu e
parameters(0) = New finreporting.ParameterValu e()
parameters(0).Name = "fundcoll"
parameters(0).Value = tbCollege.Text.ToString
parameters(1) = New finreporting.ParameterValu e()
parameters(1).Name = "funddept"
parameters(1).Value = tbDepartment.Text.ToString
parameters(2) = New finreporting.ParameterValu e()
parameters(2).Name = "funds"
parameters(2).Value = tbFund.Text.ToString
parameters(3) = New finreporting.ParameterValu e()
parameters(3).Name = "fundopenattrb"
parameters(3).Value = tbFundStatus.Text.ToString
Dim credentials As finreportingReportExecutio n.DataSour ceCredenti als() = Nothing
Dim showHideToggle As String = Nothing
Dim result As Byte() = Nothing
Dim historyID As String = Nothing
Dim reportHistoryParameters As finreportingReportExecutio n.Paramete rValue = Nothing
Dim execInfo As New finreporting.ExecutionInfo ()
Dim execHeader As New finreporting.ExecutionHead er()
Dim SessionId As String
wsre.ExecutionHeaderValue = execHeader
execInfo = wsre.LoadReport(reportfile path, historyID)
wsre.SetExecutionParameter s(paramete rs, "en-us")
SessionId = wsre.ExecutionHeaderValue. ExecutionI D
File.AppendAllText(ErrorFi le, vbCrLf + Today.ToString + "@" + TimeOfDay.ToString _
+ " Setting Parameters")
File.AppendAllText(ErrorFi le, vbCrLf + "P0=" + parameters(0).Value.ToStri ng)
File.AppendAllText(ErrorFi le, vbCrLf + "P1=" + parameters(1).Value.ToStri ng)
File.AppendAllText(ErrorFi le, vbCrLf + "P2=" + parameters(2).Value.ToStri ng)
File.AppendAllText(ErrorFi le, vbCrLf + "P3=" + parameters(3).Value.ToStri ng)
'File.AppendAllText(ErrorF ile, "SessionID: {0}" + wsre.ExecutionHeaderValue. ExecutionI D + vbCrLf)
Try
result = wsre.Render(format, devInfo, extension, mimeType, encoding, warnings, streamIDs)
execInfo = wsre.GetExecutionInfo()
Dim stream As FileStream = File.Create(filestreamfile path, result.Length)
stream.Write(result, 0, result.Length)
Response.Clear()
'Response.Redirect
Response.Buffer = True
Response.AddHeader("Conten t-Disposit ion", fileattachmentname)
Response.ContentType = mimeType
Response.BinaryWrite(resul t)
Response.Flush()
Response.Close()
stream.Close()
Catch e As Exception
File.AppendAllText(ErrorFi le, vbCrLf + Today.ToString + "@" + TimeOfDay.ToString _
+ " Catch Block in Render")
File.AppendAllText(ErrorFi le, e.Message + vbCrLf)
End Try
End Sub
Sub RenderReport()
'Private wsre As New finreporting.ReportExecuti
wsrs = New finreporting.ReportingServ
wsre = New finreporting.ReportExecuti
wsre.Credentials = System.Net.CredentialCache
wsre.Url = "http://finreporting:8080/reportserver/ReportExecution2005.asmx?wsdl"
wsrs.Credentials = System.Net.CredentialCache
wsrs.Url = "http://finerporting:8080/reportserver/ReportService2005.asmx?wsdl"
'Render Arguments
Dim format As String = Nothing
Dim devInfo As String = "<DeviceInfo><Toolbar>Fals
Dim extension As String = Nothing
Dim mimeType As String = Nothing
Dim encoding As String = "en-us"
Dim warnings As finreporting.Warning() = Nothing
Dim streamIDs As String() = Nothing
If rbPDF.Checked = True Then
reportfilepath = "/DonorRelations/FundConta
format = "PDF"
extension = "PDF"
mimeType = "application/pdf"
filestreamfilepath = "c:\inetpub\wwwroot\Schola
fileattachmentname = "attachment;filename=FundR
Else
reportfilepath = "/DonorRelations/FundConta
format = "Excel"
extension = "xls"
mimeType = "application/excel"
filestreamfilepath = "c:\inetpub\wwwroot\Schola
fileattachmentname = "attachment;filename=FundR
End If
' Prepare report parameter.
Dim parameters(4) As finreporting.ParameterValu
parameters(0) = New finreporting.ParameterValu
parameters(0).Name = "fundcoll"
parameters(0).Value = tbCollege.Text.ToString
parameters(1) = New finreporting.ParameterValu
parameters(1).Name = "funddept"
parameters(1).Value = tbDepartment.Text.ToString
parameters(2) = New finreporting.ParameterValu
parameters(2).Name = "funds"
parameters(2).Value = tbFund.Text.ToString
parameters(3) = New finreporting.ParameterValu
parameters(3).Name = "fundopenattrb"
parameters(3).Value = tbFundStatus.Text.ToString
Dim credentials As finreportingReportExecutio
Dim showHideToggle As String = Nothing
Dim result As Byte() = Nothing
Dim historyID As String = Nothing
Dim reportHistoryParameters As finreportingReportExecutio
Dim execInfo As New finreporting.ExecutionInfo
Dim execHeader As New finreporting.ExecutionHead
Dim SessionId As String
wsre.ExecutionHeaderValue = execHeader
execInfo = wsre.LoadReport(reportfile
wsre.SetExecutionParameter
SessionId = wsre.ExecutionHeaderValue.
File.AppendAllText(ErrorFi
+ " Setting Parameters")
File.AppendAllText(ErrorFi
File.AppendAllText(ErrorFi
File.AppendAllText(ErrorFi
File.AppendAllText(ErrorFi
'File.AppendAllText(ErrorF
Try
result = wsre.Render(format, devInfo, extension, mimeType, encoding, warnings, streamIDs)
execInfo = wsre.GetExecutionInfo()
Dim stream As FileStream = File.Create(filestreamfile
stream.Write(result, 0, result.Length)
Response.Clear()
'Response.Redirect
Response.Buffer = True
Response.AddHeader("Conten
Response.ContentType = mimeType
Response.BinaryWrite(resul
Response.Flush()
Response.Close()
stream.Close()
Catch e As Exception
File.AppendAllText(ErrorFi
+ " Catch Block in Render")
File.AppendAllText(ErrorFi
End Try
End Sub
Microsoft distributes Microsoft SQL Server 2008 fixes as one downloadable file. Because the fixes are cumulative, each new release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2008 fix release.
http://support.microsoft.com/kb/971068
http://support.microsoft.com/kb/971068
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Another case happens when parameters may contain trailing blank spaces in the ASP but available parameter values in the report do not, or vice versa. This causes the input parameter from ASP to not match up with available values from the report and caused a null value error. Make sure values are timmed from the ASP and SSRS side.
ASKER