all groups > sql server reporting services > march 2005 >
You're in the

sql server reporting services

group:

Dynamic Query using Web Services


Dynamic Query using Web Services David Gardner
3/24/2005 3:53:03 PM
sql server reporting services: I am accessing a report via the RS Web Service. The report is based on a
stored procedure that looks like this:

exec documents_loaded '@begindate', '@enddate'

I would like to change the parameters of the stored procedure in my VB.net
application through the webservice. Any direction on where to look?

Regards,
David Gardner

I've included my Web Services access code below:

' BEGIN CODE '


Dim rs As New ReportingService

rs.Credentials = System.Net.CredentialCache.DefaultCredentials

Dim results As Byte(), image As Byte()
Dim streamids As String(), streamid As String

'Render the report to HTML4.0
' Could also do XML, NULL, CSV, IMAGE, PDF, HTML4.0, HTML3.2, MHTML, EXCEL,
and HTMLOWC
results = rs.Render("/Sample Reports/TestReport", "HTML4.0", _
Nothing,
"<DeviceInfo><StreamRoot>/WebApplication1/</StreamRoot></DeviceInfo>",
Nothing, _
Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, streamids)

' For each image stream returned by the call to render,
' render the stream and save it to the application root
For Each streamid In streamids
image = rs.RenderStream("/Sample Reports/TestReport", "HTML4.0", streamid, _
Nothing, Nothing, Nothing, Nothing, Nothing)

Dim stream As System.IO.FileStream = _
System.IO.File.OpenWrite("D:\temp\RS\" & streamid)

stream.Write(image, 0, CInt(image.Length))
stream.Close()
Next
' Write the rendered report to the Web form
Response.BinaryWrite(results)
Re: Dynamic Query using Web Services David Gardner
3/25/2005 6:49:04 AM
Mary,

Thanks for your response. I actually found your option after I posted.
However, I'm not able to get it to work. In my report, under the "Data" tab
I have my stored procedure listed like so

documents_loaded

and the command type set to "Stored Procedure". When I run it, the
procedure asks for the begin and end date parameters and runs fine. Same
when I deploy and access the report via the URL. However, when I try and
access through web services I get the following error:

This report requires a default or user-defined value for the report
parameter 'begin_search_date'. To run or subscribe to this report, you must
provide a parameter value.

Here is my updated code where I pass the parameters (at least I thought I
did) to the report:

' BEGIN CODE '

Dim rs As New ReportingService
rs.Credentials = System.Net.CredentialCache.DefaultCredentials

Dim results As Byte(), image As Byte()
Dim streamids As String(), streamid As String

Dim parameters(1) As ParameterValue

Dim beginDate As New TestRS_local.ReportingServices.ParameterValue
beginDate.Name = "begin_search_date"
beginDate.Value = "01/01/2005"
parameters(0) = beginDate

Dim endDate As New TestRS_local.ReportingServices.ParameterValue
endDate.Name = "end_search_date"
endDate.Value = "01/31/2005"
parameters(1) = endDate

' Render the report to HTML4.0
' Could also do XML, NULL, CSV, IMAGE, PDF, HTML4.0, HTML3.2, MHTML,
EXCEL, and HTMLOWC
results = rs.Render("/PSEG/TestReport", "HTML4.0", _
Nothing,
"<DeviceInfo><StreamRoot>/WebApplication1/</StreamRoot></DeviceInfo>",
Nothing, _
Nothing, Nothing, Nothing, Nothing, parameters, Nothing, streamids)


' For each image stream returned by the call to render,
' render the stream and save it to the application root
For Each streamid In streamids

image = rs.RenderStream("/PSEG/TestReport", "HTML4.0", streamid, _
Nothing, Nothing, parameters, Nothing, Nothing)

Dim stream As System.IO.FileStream = _
System.IO.File.OpenWrite("D:\temp\RS\" & streamid)

stream.Write(image, 0, CInt(image.Length))
stream.Close()
Next
' Write the rendered report to the Web form
Response.BinaryWrite(results)

' END CODE '

Regards,
David Gardner

[quoted text, click to view]
Re: Dynamic Query using Web Services David Gardner
3/25/2005 7:25:03 AM
It is working now. It appears that there are two places that you can pass
"parameters" to the Render method. The first place (the one you suggested)
is in the fifth position. There is another spot that asks for parameters
which is the Tenth position which is actually labeled "ParametersUsed".

So this works:

results = rs.Render("/PSEG/TestReport", "HTML4.0", _
Nothing,
"<DeviceInfo><StreamRoot>/WebApplication1/</StreamRoot></DeviceInfo>",
parameters, _
Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, streamids)

But this doesn't:

results = rs.Render("/PSEG/TestReport", "HTML4.0", _
Nothing,
"<DeviceInfo><StreamRoot>/WebApplication1/</StreamRoot></DeviceInfo>",
Nothing, _
Nothing, Nothing, Nothing, Nothing, parameters, Nothing, streamids)

Thanks so much for your suggestion!

Regards,
David Gardner

[quoted text, click to view]
Re: Dynamic Query using Web Services Mary Bray [MVP]
3/25/2005 4:41:28 PM
I'd imagine you would use the parameters argument (5th argument) of the
render method, populating it with a collection of ParameterValue objects
that contain "name" and "value". These would be name="begindate" and
value="somedate" - make sure the parameters are correctly set in report
manager and you should be fine.

--

Mary Bray [SQL Server MVP]
Please reply only to newsgroups

[quoted text, click to view]

Re: Dynamic Query using Web Services Mary Bray [MVP]
3/26/2005 9:24:09 AM
Well done! I've only ever sent a complete http request for rendering

--

Mary Bray [SQL Server MVP]
Please reply only to newsgroups

[quoted text, click to view]

AddThis Social Bookmark Button