I following the instruction on http://support.microsoft.com /?kbid=875447 and did the following:
(1) I added the Web Reference http://ReportServerName/ReportServer/ReportExecution2005.asmx and named it rsReportExecution2005.
(2) In the web page, I Imports rsReportExecution2005.
(3) In the button_click event I have the following code:
Dim rsReportExec As ReportExecutionService = New ReportExecutionService
rsReportExec.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim byteResult As Byte = Nothing
Dim strReportPath As String = "ReportViewer.aspx?%2fCAIT%2frptIssuesByRole&rs:Command=Render&intProjectID=" & Me.cboProject.SelectedValue & "&nvchrWhoRan=" & Session("strEmployeeName")
Dim strFormat As String = "MSWord"
Dim strEncoding As String = ""
Dim strMineType As String = ""
Dim strExtension As String = ""
Dim wrnWarnings As Warning = Nothing
Dim strStreamIDs As String = Nothing
Dim execInfo As ExecutionInfo = New ExecutionInfo
Dim execHeader As ExecutionHeader = New ExecutionHeader
rsReportExec.ExecutionHeaderValue = execHeader
execInfo = rsReportExec.LoadReport(strReportPath, Me.cboProject.SelectedValue)
Dim strSessionID As String = rsReportExec.ExecutionHeaderValue.ExecutionID
byteResult = rsReportExec.Render(strFormat, Nothing, strExtension, strEncoding, strMineType, wrnWarnings, strStreamIDs)
I got errors on the last line above on wrnWarnings that "value of type 'rsReportExec.warning' cannot be converted to '1-dimensional array of 'rsReportExec.warning' " and on strStreamIDs that "value of type 'string' cannot be converted to '1-dimensional array of 'string'". What did I miss?
Thanks.
DanYeung
Change this:
Dim wrnWarnings As Warning = Nothing
Dim strStreamIDs As String = Nothing
to this:
Dim wrnWarnings As Warning() = Nothing
Dim strStreamIDs As String() = Nothing
You declare the variables as a single variable, but the Render function expects to see arrays in those locations
See this link:http://msdn2.microsoft.com/en-us/library/microsoft.wssux.reportingserviceswebservice.rsexecutionservice2005.reportexecutionservice.render.aspx
This give you following declaration:
Public Function Render ( _
Format As String, _
DeviceInfo As String, _
ByRef Extension As String, _
ByRef MimeType As String, _
ByRef Encoding As String, _
ByRef Warnings As Warning(), _
ByRef StreamIds As String() _
) As Byte()
|||
Thanks.
|||The example in the link http://msdn2.microsoft.com/en-us/library/microsoft.wssux.reportingserviceswebservice.rsexecutionservice2005.reportexecutionservice.render.aspx passes only one parameter (the historyID), execInfo = rs.LoadReport(reportPath, historyID);. How do I pass multiple parameters?
Thanks.
|||Take a closer look at the code example. It actually sets 3 report parameters
It sets the parameters below
' Prepare report parameter.
Dim parameters(2) As ParameterValue
parameters(0) = New ParameterValue()
parameters(0).Name = "EmpID"
parameters(0).Value = "288"
parameters(1) = New ParameterValue()
parameters(1).Name = "ReportMonth"
parameters(1).Value = "6" ' June
parameters(2) = New ParameterValue()
parameters(2).Name = "ReportYear"
parameters(2).Value = "2004"
... [clipped]...
execInfo = rs.LoadReport(reportPath, historyID)
rs.SetExecutionParameters(parameters, "en-us")
"SetExecutionParameters" is fairly obviously the command that would set the report parameters, not the LoadReport method.
You must load the report first, then assign the parameters array you created to the report using the SetExecutionParameters method.
|||Refering to execInfo = rs.LoadReport(reportPath, historyID), historyID has not been assigned value. Why is it being used and why is it required? Refering to rs.SetExecutionParameters(parameters, "en-us"), what is "en-us"?
Thanks.
DanYeung
|||In addition of the above question, how can I get the reportPath programmatically so I don't have to hard code? Please refer to the link http://msdn2.microsoft.com/en-us/library/microsoft.wssux.reportingserviceswebservice.rsexecutionservice2005.reportexecutionservice.render.aspx.
Thanks.
DanYeung
No comments:
Post a Comment