June 10, 2004 at 3:39 am
Hi, Im trying to display a report on a web page using the Web Service. Everything works fine as long as I don't have to pass any parameters. But of course I need to pass some parameters!
Here is some of my code, which is almost the same as the render example on MSN:
Private Sub renderReport()
Dim rs As New ReportingService
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
' Render arguments
Dim result As Byte() = Nothing
Dim reportPath As String = "/Rep1/Report1"
Dim format As String = "HTML4.0"
Dim historyID As String = Nothing
Dim devInfo As String = "<DeviceInfo><Toolbar>False</Toolbar><StreamRoot>imgs/" & Session.SessionID & "/</StreamRoot></DeviceInfo>"
' Prepare report parameter.
Dim parameters(1) As ParameterValue
parameters(0) = New ParameterValue
parameters(0).Name = "abo_id"
parameters(0).Value = "1714"
parameters(0).Label = "1714"
Dim credentials As DataSourceCredentials() = Nothing
Dim showHideToggle As String = Nothing
Dim encoding As String
Dim mimeType As String
Dim warnings As Warning() = Nothing
Dim reportHistoryParameters As ParameterValue() = Nothing
Dim streamIDs As String(), streamID As String
Dim sh As New SessionHeader
rs.SessionHeaderValue = sh
result = rs.Render(reportPath, format, historyID, devInfo, parameters, _
credentials, showHideToggle, encoding, mimeType, reportHistoryParameters, warnings, streamIDs)
' For each image stream returned by the call to render,
' render the stream and save it to the application root
Dim rootFolder As String = Server.MapPath("imgs/") & Session.SessionID & "\"
Dim image As Byte()
For Each streamID In streamIDs
image = rs.RenderStream("/Rep1/Report1", "HTML4.0", streamID, _
Nothing, Nothing, Nothing, Nothing, Nothing)
If Not System.IO.Directory.Exists(rootFolder) Then
System.IO.Directory.CreateDirectory(rootFolder)
End If
Dim stream As System.IO.FileStream = _
System.IO.File.OpenWrite(rootFolder & streamID)
stream.Write(image, 0, CInt(image.Length))
stream.Close()
Next
Response.BinaryWrite(result)
End Sub
Here is the error message i receive:
Exception Details: System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: The value of parameter 'Parameters' is not valid. Check the documentation for information about valid values. ---> Microsoft.ReportingServices.Diagnostics.Utilities.InvalidParameterException: The value of parameter 'Parameters' is not valid. Check the documentation for information about valid values. at Microsoft.ReportingServices.WebServer.ReportingService.CheckParameterArray(ParameterValueOrFieldReference[] parameters, String parameterName) at Microsoft.ReportingServices.WebServer.ReportingService.Render(String Report, String Format, String HistoryID, String DeviceInfo, ParameterValue[] Parameters, DataSourceCredentials[] Credentials, String ShowHideToggle, Byte[]& Result, String& Encoding, String& MimeType, ParameterValue[]& ParametersUsed, Warning[]& Warnings, String[]& StreamIds) --- End of inner exception stack trace --- at Microsoft.ReportingServices.WebServer.ReportingService.Render(String Report, String Format, String HistoryID, String DeviceInfo, ParameterValue[] Parameters, DataSourceCredentials[] Credentials, String ShowHideToggle, Byte[]& Result, String& Encoding, String& MimeType, ParameterValue[]& ParametersUsed, Warning[]& Warnings, String[]& StreamIds)
I have ofcourse checked that the parameter is called abo_id, and ValidValues are 1713, 1714. I have tried with both Integer and String type.
When i call the report directly like this:
http://localhost/ReportServer?/Rep1/Report1&abo_id=1714&rs:Command=Render&rs:Format=HTML4.0
it works, and if I take away the parameter from the report it also works.
I am stumped! Can anyone help me out?? I will be very gratefull for any help or suggestion!
Sjur
June 10, 2004 at 4:10 am
And ofcourse, after struggeling with this for 2 days i stumble uppon the solution 5 minutes after I post the problem. But I figure since I followed the example from Microsoft and got the error, someone is bound to get into the same problem. So I'll leave the post and here comes the solution:
This doesn't work:
Dim parameters(1) As ParameterValue
This does work:
Dim parameters As Array = Array.CreateInstance(GetType(ParameterValue), 1)
When i fixed that I only got one small error from the code in the original post. I need to supply the RenderStream method with the parameters aswell, like this:
image = rs.RenderStream("/Rep1/Report1", "HTML4.0", streamID, _
Nothing, Nothing, parameters, Nothing, Nothing)
After that everything works just fine.
If anyone wants to explain why "dim parameters(1) as ParameterValue" doesn't work, feel free, cause I don't know.
Sjur
June 14, 2004 at 8:10 pm
I suspect there is a difference between how the decalrations work....
dim X as (some kind of array declaration)
Vs.
Dim Y(n) as type
two things:
X is a reference to an array whose size will be found at run time
Y is an array of n elements
I suspect that if we dumped the MSIL code we would see different parameter loading going on under to hood.
thats my guess anyway.
May 26, 2005 at 9:51 am
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply