Discussion:
Is there an easier way to retrieve parameter query definitions?
(too old to reply)
Chris G.
2007-01-25 18:42:01 UTC
Permalink
SSRS 2005

I am building a custom asp.net report parameter page interface for our
Reporting Services reports. We want to leverage as much of the design
information contained in the report definitions as possible to automate the
building of the report parameter pages.

I see how I can use the ReportViewer methods and the web services interface
to obtain report parameter definition information, but I do not see any
properties or methods within these interfaces for finding out the queries
(datasets) that are defined for populating the drop down lists for the
parameters.

I do see that I can use the web service interface to get the .rdl file for
the report and search it to get the dataset definitions for the parameters.
But my question is, is this the only way to do so, or is there a more direct
method available? Am I overlooking a simpler approach?

Thanks!

-- Chris
--
Chris, SSSI
Wei Lu [MSFT]
2007-01-26 02:33:26 UTC
Permalink
Hello Chris,

There is a DataSetDefinition Class in the Web Service.

You could try to use this to get the dataset information.

Sincerely,

Wei Lu

Microsoft Online Community Support

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Chris G.
2007-01-26 03:41:01 UTC
Permalink
Hi Wei Lu,
Post by Wei Lu [MSFT]
Post by Wei Lu [MSFT]
There is a DataSetDefinition Class in the Web Service.
Will that tell me which DataSets are used by each parameter?

-- Chris
--
Chris, SSSI
Post by Wei Lu [MSFT]
Hello Chris,
There is a DataSetDefinition Class in the Web Service.
You could try to use this to get the dataset information.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Wei Lu [MSFT]
2007-01-26 06:37:02 UTC
Permalink
Hello Chris,

Do you mean you wants to know each dataset are using what parameters or
which datasets are using one parameter?

Or you wants to know each parameter are using which dataset to build the
value range?

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Wei Lu [MSFT]
2007-01-30 12:26:24 UTC
Permalink
Hi ,

How is everything going? Please feel free to let me know if you need any
assistance.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Chris G.
2007-01-30 17:18:01 UTC
Permalink
Hi Wei Lu,

What I am doing currently is using the
ReportViewer.ServerReport.GetParameters() method to get the parameter
definitions.

Then I am going to dynamically create ASP.NET web controls for the parameter
definitions in the returned collection. If a parameter has valid and default
values defined by a DataSet, I need to know what that DataSet is so I can
populate the drop down list and preselect the default values. But the
Microsoft.Reporting.WebForms.ReportParameterInfoCollection returned by
GetParameters() does not seem to have a property which provides the valid and
default value DataSets. Only properties (AreDefaultValuesQueryBased and
AreValidValuesQueryBased) which specify if queries were defined. Am I missing
something? An undocumented property maybe?

So my question is, how do I know what DataSets are used to provide the
values for the parameters that have drop down lists? I know I can retrieve
the .rdl for the report and parse it myself, but I wanted to know if there is
a better way to do this without having to manually examine the .rdl file.

Thanks!

-- Chris
--
Chris, SSSI
Post by Wei Lu [MSFT]
Hi ,
How is everything going? Please feel free to let me know if you need any
assistance.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Rowen
2007-01-31 00:43:54 UTC
Permalink
Post by Chris G.
Hi Wei Lu,
What I am doing currently is using the
ReportViewer.ServerReport.GetParameters() method to get the parameter
definitions.
Then I am going to dynamically create ASP.NET web controls for the parameter
definitions in the returned collection. If a parameter has valid and default
values defined by a DataSet, I need to know what that DataSet is so I can
populate the drop down list and preselect the default values. But the
Microsoft.Reporting.WebForms.ReportParameterInfoCollection returned by
GetParameters() does not seem to have a property which provides the valid and
default value DataSets. Only properties (AreDefaultValuesQueryBased and
AreValidValuesQueryBased) which specify if queries were defined. Am I missing
something? An undocumented property maybe?
So my question is, how do I know what DataSets are used to provide the
values for the parameters that have drop down lists? I know I can retrieve
the .rdl for the report and parse it myself, but I wanted to know if there is
a better way to do this without having to manually examine the .rdl file.
Thanks!
-- Chris
Hi Chris,

I have done something similar to what you require using Reporting
Services 2003. I use the call

Dim paramValues() As ParameterValue
parameters = rs.GetReportParameters(reportPath, Nothing, True,
paramValues, Nothing)

each parameter in the resulting parameters collection has a property
called' ValidValues' which contains the list of values you would want
to display eg. in a drop down list. It gets a little more complicated
when you have dependencies (one list dependent on another) but that is
the basic method I used to get the parameter lists.

Rowen
Chris G.
2007-02-01 19:33:01 UTC
Permalink
Hi Rowen,

Thank for your reply!

It is funny that you mention rs.GetReportParameters()...I just started to
look at that after I made my post.
Post by Rowen
It gets a little more complicated when you have dependencies
That is exactly the problem I am up against. Did you solve this problem? If
so does it require setting the parameter value in the report for a parent
parameter and then calling rs.GetReportParameters() again to get the updated
child parameter? Or is it even trickier than that?

Any further insight you can provide would be great!

-- Chris
--
Chris, SSSI
Post by Rowen
Hi Wei Lu,
What I am doing currently is using the
ReportViewer.ServerReport.GetParameters() method to get the parameter
definitions.
Then I am going to dynamically create ASP.NET web controls for the parameter
definitions in the returned collection. If a parameter has valid and default
values defined by a DataSet, I need to know what that DataSet is so I can
populate the drop down list and preselect the default values. But the
Microsoft.Reporting.WebForms.ReportParameterInfoCollection returned by
GetParameters() does not seem to have a property which provides the valid and
default value DataSets. Only properties (AreDefaultValuesQueryBased and
AreValidValuesQueryBased) which specify if queries were defined. Am I missing
something? An undocumented property maybe?
So my question is, how do I know what DataSets are used to provide the
values for the parameters that have drop down lists? I know I can retrieve
the .rdl for the report and parse it myself, but I wanted to know if there is
a better way to do this without having to manually examine the .rdl file.
Thanks!
-- Chris
Hi Chris,
I have done something similar to what you require using Reporting
Services 2003. I use the call
Dim paramValues() As ParameterValue
parameters = rs.GetReportParameters(reportPath, Nothing, True,
paramValues, Nothing)
each parameter in the resulting parameters collection has a property
called' ValidValues' which contains the list of values you would want
to display eg. in a drop down list. It gets a little more complicated
when you have dependencies (one list dependent on another) but that is
the basic method I used to get the parameter lists.
Rowen
Rowen
2007-02-02 00:44:32 UTC
Permalink
Post by Chris G.
It gets a little more complicated when you have dependencies
That is exactly the problem I am up against. Did you solve this problem? If
so does it require setting the parameter value in the report for a parent
parameter and then calling rs.GetReportParameters() again to get the updated
child parameter? Or is it even trickier than that?
Yes, what you suggest is correct. The paramValues array that you pass
into the method call should hold any parent ParameterValue objects
(with name and value specified). Then the dependent list should be
populated.

Hence, on the client application, you need to keep track of what
parameters have been selected and pass these down to the
GetReportParameters() call. I found the Dependencies property on the
ReportParameter object useful so as to determine whether a parameter
requires the parent value before its own list of valid values can be
populated.

I did get it working in the end. Let me know if you require further
explanation.

Rowen
Chris G.
2007-02-08 22:08:01 UTC
Permalink
Hi Rowen,

I have done some more thinking and research, and if you have some time I
have a view additional questions for you.

First, we started looking at a Code Project example
http://www.codeproject.com/sqlrs/SQLRSViewer.asp which seems to follow the
same basic approach that you are. I think I get the concept, but I have some
follow up questions for you:

1. So it seems that I do not need to know any of the dataset queries or
stored procedures behind the report parameter definitions because
GetReportParameters() hides all of those details. Is that correct?

2. I need to keep calling GetReportParameters() and passing in the parameter
values selected by the user on my custom parameter page until all parameters
have .State = HasValidValue and then I can run the report for the user. Is
that correct?

Are you using the Report Viewer Web Control? We are using it to display the
report and I am wondering what if any complexities that is going to add. I
want to use the Report Viewer Control so I do not have to implement the
paging logic and controls for exporting, searching, etc. I am planning to
just hide the parameter section that is managed by the Report Viewer Control.

3. I am guessing that I will just use your GetReportParameters() approach
until all parameters have valid values, and then use
ReportViewer.ServerReport.SetParameters() to set up the Report Viewer Control
to render the report. Is this the same approach that you used?

4. If the above is the approach that you used, are there any gotchas that
you can warn me about, or any workarounds you remember having to implement?

Thank you for any further information that you can provide!

-- Chris
--
Chris, SSSI
Post by Rowen
Post by Chris G.
It gets a little more complicated when you have dependencies
That is exactly the problem I am up against. Did you solve this problem? If
so does it require setting the parameter value in the report for a parent
parameter and then calling rs.GetReportParameters() again to get the updated
child parameter? Or is it even trickier than that?
Yes, what you suggest is correct. The paramValues array that you pass
into the method call should hold any parent ParameterValue objects
(with name and value specified). Then the dependent list should be
populated.
Hence, on the client application, you need to keep track of what
parameters have been selected and pass these down to the
GetReportParameters() call. I found the Dependencies property on the
ReportParameter object useful so as to determine whether a parameter
requires the parent value before its own list of valid values can be
populated.
I did get it working in the end. Let me know if you require further
explanation.
Rowen
Wei Lu [MSFT]
2007-02-13 01:54:57 UTC
Permalink
Hello Chris,

I would like to answer some of your questions:

1. GetReportParameter hide all of the details, you did not need to know the
detailed information.

2. From your description, I think your approach is correct.

As for question 3 & 4, I could not answer it but for me, I think your
approach will be fine.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Rowen
2007-02-13 04:21:01 UTC
Permalink
Hi Chris,
Post by Chris G.
1. So it seems that I do not need to know any of the dataset queries or
stored procedures behind the report parameter definitions because
GetReportParameters() hides all of those details. Is that correct?
Yes, that is correct
Post by Chris G.
2. I need to keep calling GetReportParameters() and passing in the parameter
values selected by the user on my custom parameter page until all parameters
have .State = HasValidValue and then I can run the report for the user. Is
that correct?
This looks like it should work. The probklem is in knowing when to re-
draw the parameters. I did not use the HasValidValue property.

Each request for parameter information on the client involved two
calls to GetReportParameters. WIth the first call I got the basic list
of parameters. Then I looped around this, setting up the existing
values array for the second call, and also deciding which parameters
were parent i.e. were part of the dependency set of another.

I wanted to know when a parent parameter was selected by the user, so
I could refresh the page (hence re-drawing with child parameters
populated). In order to achieve this I wrapped up the parameter object
with my own version, and added a flag to tell me whether it is a
parent or not, by looping through all parameters and checking the
dependencies list (whcih contains the names of parent parameters).

With this information, when a user changes that parameter value, I
know whether or not a page refresh is necessary for other parameters.
This was further improved by refreshing the parameter prompts via an
ajax call to avoid the nasty page refreshes.

I assumed that a selected value would always be valid, and defaulted
to the first item in the list. You also have to be mindful to re-
select previously selected values on re-draw.
Post by Chris G.
Are you using the Report Viewer Web Control? We are using it to display the
report and I am wondering what if any complexities that is going to add. I
want to use the Report Viewer Control so I do not have to implement the
paging logic and controls for exporting, searching, etc. I am planning to
just hide the parameter section that is managed by the Report Viewer Control.
I did not use the Report Viewer Web Control as paging was not required
for my solution.
Post by Chris G.
3. I am guessing that I will just use your GetReportParameters() approach
until all parameters have valid values, and then use
ReportViewer.ServerReport.SetParameters() to set up the Report Viewer Control
to render the report. Is this the same approach that you used?
I used the ReportServer.Render method passing in the report path,
paramaters and format. However, as already mentioned, with this
approach, using HTML rendering, you do not get paging. One advantage
is that you can generate a report directly as PDF, Excel or other
supported formats and allow the user to save to their desktop. This
also involves a few tricks in order to get the file save prompt
without popping up a blank browser window.
Post by Chris G.
4. If the above is the approach that you used, are there any gotchas that
you can warn me about, or any workarounds you remember having to implement?
It is useful to adopt a naming convention for your report parameters
so that you know whether to draw a textbox, combo or datepicker etc.
Using this technique, I also decided that there were some parameters
that would always be hidden from the user where the application could
push a value into automatically depending on user settings.
Post by Chris G.
Thank you for any further information that you can provide!
-- Chris
Chris G.
2007-02-13 17:53:00 UTC
Permalink
Rowen,

Thank you once again for providing such detailed and useful information. I
hope I will be able to return the favor one day.

One last question...how many hours of work would you estimate that it took
you to implement your custom report parameter page solution (R&D, design,
implementation and testing)?

Thank you!

-- Chris
--
Chris, SSSI
Post by Rowen
Hi Chris,
Post by Chris G.
1. So it seems that I do not need to know any of the dataset queries or
stored procedures behind the report parameter definitions because
GetReportParameters() hides all of those details. Is that correct?
Yes, that is correct
Post by Chris G.
2. I need to keep calling GetReportParameters() and passing in the parameter
values selected by the user on my custom parameter page until all parameters
have .State = HasValidValue and then I can run the report for the user. Is
that correct?
This looks like it should work. The probklem is in knowing when to re-
draw the parameters. I did not use the HasValidValue property.
Each request for parameter information on the client involved two
calls to GetReportParameters. WIth the first call I got the basic list
of parameters. Then I looped around this, setting up the existing
values array for the second call, and also deciding which parameters
were parent i.e. were part of the dependency set of another.
I wanted to know when a parent parameter was selected by the user, so
I could refresh the page (hence re-drawing with child parameters
populated). In order to achieve this I wrapped up the parameter object
with my own version, and added a flag to tell me whether it is a
parent or not, by looping through all parameters and checking the
dependencies list (whcih contains the names of parent parameters).
With this information, when a user changes that parameter value, I
know whether or not a page refresh is necessary for other parameters.
This was further improved by refreshing the parameter prompts via an
ajax call to avoid the nasty page refreshes.
I assumed that a selected value would always be valid, and defaulted
to the first item in the list. You also have to be mindful to re-
select previously selected values on re-draw.
Post by Chris G.
Are you using the Report Viewer Web Control? We are using it to display the
report and I am wondering what if any complexities that is going to add. I
want to use the Report Viewer Control so I do not have to implement the
paging logic and controls for exporting, searching, etc. I am planning to
just hide the parameter section that is managed by the Report Viewer Control.
I did not use the Report Viewer Web Control as paging was not required
for my solution.
Post by Chris G.
3. I am guessing that I will just use your GetReportParameters() approach
until all parameters have valid values, and then use
ReportViewer.ServerReport.SetParameters() to set up the Report Viewer Control
to render the report. Is this the same approach that you used?
I used the ReportServer.Render method passing in the report path,
paramaters and format. However, as already mentioned, with this
approach, using HTML rendering, you do not get paging. One advantage
is that you can generate a report directly as PDF, Excel or other
supported formats and allow the user to save to their desktop. This
also involves a few tricks in order to get the file save prompt
without popping up a blank browser window.
Post by Chris G.
4. If the above is the approach that you used, are there any gotchas that
you can warn me about, or any workarounds you remember having to implement?
It is useful to adopt a naming convention for your report parameters
so that you know whether to draw a textbox, combo or datepicker etc.
Using this technique, I also decided that there were some parameters
that would always be hidden from the user where the application could
push a value into automatically depending on user settings.
Post by Chris G.
Thank you for any further information that you can provide!
-- Chris
Rowen
2007-02-15 02:27:47 UTC
Permalink
Post by Chris G.
One last question...how many hours of work would you estimate that it took
you to implement your custom report parameter page solution (R&D, design,
implementation and testing)?
I'm not sure I can be much help to you here... This was only a small
part of the project I was working on and it developed as the project
went on, so I cant split it out say accurately. As a rough estimate I
would say it took about 1 - 2 weeks effort for the reporting interface
requirements.
MacUser
2007-03-20 20:16:08 UTC
Permalink
Can you let me know how I can get the File Save prompt without popping up a
blank browser window."

Thanks in Advance
Post by Rowen
Post by Chris G.
One last question...how many hours of work would you estimate that it took
you to implement your custom report parameter page solution (R&D, design,
implementation and testing)?
I'm not sure I can be much help to you here... This was only a small
part of the project I was working on and it developed as the project
went on, so I cant split it out say accurately. As a rough estimate I
would say it took about 1 - 2 weeks effort for the reporting interface
requirements.
Rowen
2007-03-21 05:41:59 UTC
Permalink
Post by MacUser
Can you let me know how I can get the File Save prompt without popping up a
blank browser window."
Thanks in Advance
Post by Rowen
Post by Chris G.
One last question...how many hours of work would you estimate that it took
you to implement your custom report parameter page solution (R&D, design,
implementation and testing)?
I'm not sure I can be much help to you here... This was only a small
part of the project I was working on and it developed as the project
went on, so I cant split it out say accurately. As a rough estimate I
would say it took about 1 - 2 weeks effort for the reporting interface
requirements.
I redirect to a page that is capable of displaying a html report, or
downloading the report as a file, depending on the parameters passed
in.

On page load, I call the function ShowReport which looks like this:

Private Sub ShowReport()

' get the report path from the querystring
Dim reportPath As String = Request.QueryString("ReportPath")
Dim format As String = Request.QueryString ("ReportFormat")
Dim result As Byte() = Nothing

' get the report parameters and match up the values using
querystring values
'' retrieve all parameters
Dim parameters As New ReportParameterDataEntityCollection

For Each parameter As String In Request.QueryString
If Not (parameter.Equals("ReportPath") Or
parameter.Equals("ReportFormat")) Then
Dim objParameter As New ReportParameterDataEntity
objParameter.Name = parameter
objParameter.Value = Request.QueryString(parameter)
parameters.add(objParameter)
End If
Next

' use report manager
Dim ReportManager As IReportManager
ReportManager =
RemotingHelper.GetObject(GetType(IReportManager))
result = ReportManager.GenerateReport(Me.ActiveUserID,
reportPath, parameters, format)

Select Case format.ToUpper
Case "HTML4.0", "HTML3.2"
Dim reportContent As String =
System.Text.Encoding.UTF8.GetString(result)
litReportDetails.Text = reportContent
litPrintReportDetails.Text = reportContent

Case "PDF"
Dim fileName As String
fileName = reportPath.Substring(reportPath.LastIndexOf
("/") + 1, reportPath.Length - reportPath.LastIndexOf("/") - 1)
fileName = fileName & Now.ToString("ddMMyyyy-HHmmss")
& ".pdf"
DownloadFile(fileName, result)

Case "EXCEL"
Dim fileName As String
fileName =
reportPath.Substring(reportPath.LastIndexOf("/") + 1,
reportPath.Length - reportPath.LastIndexOf ("/") - 1)
fileName = fileName & Now.ToString("ddMMyyyy-HHmmss")
& ".xls"
DownloadFile(fileName, result)

Case "CSV"
Dim fileName As String
fileName =
reportPath.Substring(reportPath.LastIndexOf("/") + 1,
reportPath.Length - reportPath.LastIndexOf("/") - 1)
fileName = fileName & Now.ToString("ddMMyyyy-HHmmss")
& ".csv"
DownloadFile(fileName, result)

End Select

End Sub

Private Sub DownloadFile(ByVal FileName As String, ByRef b As
Byte())
Response.ClearHeaders()
Response.Clear()
' The first header ensures that the file name
' is correct on the client side. This is extremely important!
If you
' don't add this header, the browser will make
' some sort of arbitrary decision as to what the file should
be called.
' It will either offer no name and force the user to select a
name
' (As we all know, this is like giving a two-year-old a loaded
gun)
' or it will simply name the file after the web page
' it's calling (eg. MyFileServer.aspx). This will save without
any problem
' but when the user tries to open the file, their system
' will tell them it doesn't know what to do with a *.aspx file
' and you're going to slowly go insane over the next
' six months with support calls, trying to explain to users
how to
' change the file extension from *.aspx to *.pdf on their
system
Response.AddHeader("Content-disposition", "attachment;
filename=" & FileName)

' Next, we need to tell the browser what type of content
' we're serving.
' I'm using a standard application/octet-stream content type.
' It's better to find out exactly what MIME type your
particular
' file extension is defined under, as this should produce
' better browser behaviour.
' However, for our purposes, this will work just fine
' This header tells the browser that it is serving
' an application file as a byte stream.
' The browser will know immediately
' that it shouldn't serve this file as text and will open
' the File Download box instead,
' in which it offers the user the ability to save
' the file. It will also use the Content-disposition header
' (see above) to auto-populate
' the Save File dialog box with the file's name
Response.ContentType = "application/octet-stream"

' Now our headers are added, we can serve the content.
' To do this, we use the BinaryWrite() method of the server
object
' This successfully streams our external file to the user,
' despite the fact that the file doesn't exist
' anywhere inside the web application
Response.BinaryWrite(b)

' Call Response.End() so that no more
' content goes through to the client.
' The file has been downloaded,
' but if this method is not called, the page
' will continue downloading any remaining
' html/ text content and mess up the resulting stream.
' This method call ensures that the downloaded
' file doesn't end up corrupted with unwanted data
Response.End()

End Sub


I pass in parameters as name value pairs in the querystring.

ReportManager.GenerateReport is a wraper to the reporting services web
service which returns the report as a byte array.

This has been tested in IE only.

Hope this helps,

Rowen
Chris G.
2007-02-01 19:34:01 UTC
Permalink
Wei Lu,

Does Microsoft have anything to add in regards to my 1/30/2007 post?

Thanks!

-- Chris
--
Chris, SSSI
Post by Wei Lu [MSFT]
Hi ,
How is everything going? Please feel free to let me know if you need any
assistance.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Wei Lu [MSFT]
2007-02-02 08:02:57 UTC
Permalink
Hello Chris,

So far, I would like to thanksRowen's great provide.

Please let me know if you still have any concern.

Thanks!

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Oscar Mendoza
2012-02-28 22:59:51 UTC
Permalink
Hi,

I have been spending weeks on trying to create a report viewer wrapper that creating a dropbox box dynamicly based on the datasets. Did you ever find a solution to your problem?
Post by Chris G.
SSRS 2005
I am building a custom asp.net report parameter page interface for our
Reporting Services reports. We want to leverage as much of the design
information contained in the report definitions as possible to automate the
building of the report parameter pages.
I see how I can use the ReportViewer methods and the web services interface
to obtain report parameter definition information, but I do not see any
properties or methods within these interfaces for finding out the queries
(datasets) that are defined for populating the drop down lists for the
parameters.
I do see that I can use the web service interface to get the .rdl file for
the report and search it to get the dataset definitions for the parameters.
But my question is, is this the only way to do so, or is there a more direct
method available? Am I overlooking a simpler approach?
Thanks!
-- Chris
--
Chris, SSSI
Post by Wei Lu [MSFT]
Hello Chris,
There is a DataSetDefinition Class in the Web Service.
You could try to use this to get the dataset information.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Post by Chris G.
Hi Wei Lu,
Will that tell me which DataSets are used by each parameter?
-- Chris
--
Chris, SSSI
Post by Wei Lu [MSFT]
Hello Chris,
Do you mean you wants to know each dataset are using what parameters or
which datasets are using one parameter?
Or you wants to know each parameter are using which dataset to build the
value range?
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Post by Wei Lu [MSFT]
Hi ,
How is everything going? Please feel free to let me know if you need any
assistance.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Post by Chris G.
Hi Wei Lu,
What I am doing currently is using the
ReportViewer.ServerReport.GetParameters() method to get the parameter
definitions.
Then I am going to dynamically create ASP.NET web controls for the parameter
definitions in the returned collection. If a parameter has valid and default
values defined by a DataSet, I need to know what that DataSet is so I can
populate the drop down list and preselect the default values. But the
Microsoft.Reporting.WebForms.ReportParameterInfoCollection returned by
GetParameters() does not seem to have a property which provides the valid and
default value DataSets. Only properties (AreDefaultValuesQueryBased and
AreValidValuesQueryBased) which specify if queries were defined. Am I missing
something? An undocumented property maybe?
So my question is, how do I know what DataSets are used to provide the
values for the parameters that have drop down lists? I know I can retrieve
the .rdl for the report and parse it myself, but I wanted to know if there is
a better way to do this without having to manually examine the .rdl file.
Thanks!
-- Chris
--
Chris, SSSI
Post by Rowen
Hi Chris,
I have done something similar to what you require using Reporting
Services 2003. I use the call
Dim paramValues() As ParameterValue
parameters = rs.GetReportParameters(reportPath, Nothing, True,
paramValues, Nothing)
each parameter in the resulting parameters collection has a property
called' ValidValues' which contains the list of values you would want
to display eg. in a drop down list. It gets a little more complicated
when you have dependencies (one list dependent on another) but that is
the basic method I used to get the parameter lists.
Rowen
Post by Chris G.
Hi Rowen,
Thank for your reply!
It is funny that you mention rs.GetReportParameters()...I just started to
look at that after I made my post.
That is exactly the problem I am up against. Did you solve this problem? If
so does it require setting the parameter value in the report for a parent
parameter and then calling rs.GetReportParameters() again to get the updated
child parameter? Or is it even trickier than that?
Any further insight you can provide would be great!
-- Chris
--
Chris, SSSI
Post by Chris G.
Wei Lu,
Does Microsoft have anything to add in regards to my 1/30/2007 post?
Thanks!
-- Chris
--
Chris, SSSI
Post by Rowen
Yes, what you suggest is correct. The paramValues array that you pass
into the method call should hold any parent ParameterValue objects
(with name and value specified). Then the dependent list should be
populated.
Hence, on the client application, you need to keep track of what
parameters have been selected and pass these down to the
GetReportParameters() call. I found the Dependencies property on the
ReportParameter object useful so as to determine whether a parameter
requires the parent value before its own list of valid values can be
populated.
I did get it working in the end. Let me know if you require further
explanation.
Rowen
Post by Wei Lu [MSFT]
Hello Chris,
So far, I would like to thanksRowen's great provide.
Please let me know if you still have any concern.
Thanks!
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Post by Chris G.
Hi Rowen,
I have done some more thinking and research, and if you have some time I
have a view additional questions for you.
First, we started looking at a Code Project example
http://www.codeproject.com/sqlrs/SQLRSViewer.asp which seems to follow the
same basic approach that you are. I think I get the concept, but I have some
1. So it seems that I do not need to know any of the dataset queries or
stored procedures behind the report parameter definitions because
GetReportParameters() hides all of those details. Is that correct?
2. I need to keep calling GetReportParameters() and passing in the parameter
values selected by the user on my custom parameter page until all parameters
have .State = HasValidValue and then I can run the report for the user. Is
that correct?
Are you using the Report Viewer Web Control? We are using it to display the
report and I am wondering what if any complexities that is going to add. I
want to use the Report Viewer Control so I do not have to implement the
paging logic and controls for exporting, searching, etc. I am planning to
just hide the parameter section that is managed by the Report Viewer Control.
3. I am guessing that I will just use your GetReportParameters() approach
until all parameters have valid values, and then use
ReportViewer.ServerReport.SetParameters() to set up the Report Viewer Control
to render the report. Is this the same approach that you used?
4. If the above is the approach that you used, are there any gotchas that
you can warn me about, or any workarounds you remember having to implement?
Thank you for any further information that you can provide!
-- Chris
--
Chris, SSSI
Post by Wei Lu [MSFT]
Hello Chris,
1. GetReportParameter hide all of the details, you did not need to know the
detailed information.
2. From your description, I think your approach is correct.
As for question 3 & 4, I could not answer it but for me, I think your
approach will be fine.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Post by Rowen
Hi Chris,
Yes, that is correct
This looks like it should work. The probklem is in knowing when to re-
draw the parameters. I did not use the HasValidValue property.
Each request for parameter information on the client involved two
calls to GetReportParameters. WIth the first call I got the basic list
of parameters. Then I looped around this, setting up the existing
values array for the second call, and also deciding which parameters
were parent i.e. were part of the dependency set of another.
I wanted to know when a parent parameter was selected by the user, so
I could refresh the page (hence re-drawing with child parameters
populated). In order to achieve this I wrapped up the parameter object
with my own version, and added a flag to tell me whether it is a
parent or not, by looping through all parameters and checking the
dependencies list (whcih contains the names of parent parameters).
With this information, when a user changes that parameter value, I
know whether or not a page refresh is necessary for other parameters.
This was further improved by refreshing the parameter prompts via an
ajax call to avoid the nasty page refreshes.
I assumed that a selected value would always be valid, and defaulted
to the first item in the list. You also have to be mindful to re-
select previously selected values on re-draw.
I did not use the Report Viewer Web Control as paging was not required
for my solution.
I used the ReportServer.Render method passing in the report path,
paramaters and format. However, as already mentioned, with this
approach, using HTML rendering, you do not get paging. One advantage
is that you can generate a report directly as PDF, Excel or other
supported formats and allow the user to save to their desktop. This
also involves a few tricks in order to get the file save prompt
without popping up a blank browser window.
It is useful to adopt a naming convention for your report parameters
so that you know whether to draw a textbox, combo or datepicker etc.
Using this technique, I also decided that there were some parameters
that would always be hidden from the user where the application could
push a value into automatically depending on user settings.
Post by Chris G.
Rowen,
Thank you once again for providing such detailed and useful information. I
hope I will be able to return the favor one day.
One last question...how many hours of work would you estimate that it took
you to implement your custom report parameter page solution (R&D, design,
implementation and testing)?
Thank you!
-- Chris
--
Chris, SSSI
Post by Rowen
I'm not sure I can be much help to you here... This was only a small
part of the project I was working on and it developed as the project
went on, so I cant split it out say accurately. As a rough estimate I
would say it took about 1 - 2 weeks effort for the reporting interface
requirements.
Post by MacUser
Can you let me know how I can get the File Save prompt without popping up a
blank browser window."
Thanks in Advance
Post by Rowen
I redirect to a page that is capable of displaying a html report, or
downloading the report as a file, depending on the parameters passed
in.
Private Sub ShowReport()
' get the report path from the querystring
Dim reportPath As String = Request.QueryString("ReportPath")
Dim format As String = Request.QueryString ("ReportFormat")
Dim result As Byte() = Nothing
' get the report parameters and match up the values using
querystring values
'' retrieve all parameters
Dim parameters As New ReportParameterDataEntityCollection
For Each parameter As String In Request.QueryString
If Not (parameter.Equals("ReportPath") Or
parameter.Equals("ReportFormat")) Then
Dim objParameter As New ReportParameterDataEntity
objParameter.Name = parameter
objParameter.Value = Request.QueryString(parameter)
parameters.add(objParameter)
End If
Next
' use report manager
Dim ReportManager As IReportManager
ReportManager =
RemotingHelper.GetObject(GetType(IReportManager))
result = ReportManager.GenerateReport(Me.ActiveUserID,
reportPath, parameters, format)
Select Case format.ToUpper
Case "HTML4.0", "HTML3.2"
Dim reportContent As String =
System.Text.Encoding.UTF8.GetString(result)
litReportDetails.Text = reportContent
litPrintReportDetails.Text = reportContent
Case "PDF"
Dim fileName As String
fileName = reportPath.Substring(reportPath.LastIndexOf
("/") + 1, reportPath.Length - reportPath.LastIndexOf("/") - 1)
fileName = fileName & Now.ToString("ddMMyyyy-HHmmss")
& ".pdf"
DownloadFile(fileName, result)
Case "EXCEL"
Dim fileName As String
fileName =
reportPath.Substring(reportPath.LastIndexOf("/") + 1,
reportPath.Length - reportPath.LastIndexOf ("/") - 1)
fileName = fileName & Now.ToString("ddMMyyyy-HHmmss")
& ".xls"
DownloadFile(fileName, result)
Case "CSV"
Dim fileName As String
fileName =
reportPath.Substring(reportPath.LastIndexOf("/") + 1,
reportPath.Length - reportPath.LastIndexOf("/") - 1)
fileName = fileName & Now.ToString("ddMMyyyy-HHmmss")
& ".csv"
DownloadFile(fileName, result)
End Select
End Sub
Private Sub DownloadFile(ByVal FileName As String, ByRef b As
Byte())
Response.ClearHeaders()
Response.Clear()
' The first header ensures that the file name
' is correct on the client side. This is extremely important!
If you
' don't add this header, the browser will make
' some sort of arbitrary decision as to what the file should
be called.
' It will either offer no name and force the user to select a
name
' (As we all know, this is like giving a two-year-old a loaded
gun)
' or it will simply name the file after the web page
' it's calling (eg. MyFileServer.aspx). This will save without
any problem
' but when the user tries to open the file, their system
' will tell them it doesn't know what to do with a *.aspx file
' and you're going to slowly go insane over the next
' six months with support calls, trying to explain to users
how to
' change the file extension from *.aspx to *.pdf on their
system
Response.AddHeader("Content-disposition", "attachment;
filename=" & FileName)
' Next, we need to tell the browser what type of content
' we're serving.
' I'm using a standard application/octet-stream content type.
' It's better to find out exactly what MIME type your
particular
' file extension is defined under, as this should produce
' better browser behaviour.
' However, for our purposes, this will work just fine
' This header tells the browser that it is serving
' an application file as a byte stream.
' The browser will know immediately
' that it shouldn't serve this file as text and will open
' the File Download box instead,
' in which it offers the user the ability to save
' the file. It will also use the Content-disposition header
' (see above) to auto-populate
' the Save File dialog box with the file's name
Response.ContentType = "application/octet-stream"
' Now our headers are added, we can serve the content.
' To do this, we use the BinaryWrite() method of the server
object
' This successfully streams our external file to the user,
' despite the fact that the file doesn't exist
' anywhere inside the web application
Response.BinaryWrite(b)
' Call Response.End() so that no more
' content goes through to the client.
' The file has been downloaded,
' but if this method is not called, the page
' will continue downloading any remaining
' html/ text content and mess up the resulting stream.
' This method call ensures that the downloaded
' file doesn't end up corrupted with unwanted data
Response.End()
End Sub
I pass in parameters as name value pairs in the querystring.
ReportManager.GenerateReport is a wraper to the reporting services web
service which returns the report as a byte array.
This has been tested in IE only.
Hope this helps,
Rowen
Continue reading on narkive:
Loading...