Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Analysis Server and Reporting Services (2005)
 Open Reporting Services report using ReportViewer

Author  Topic 

danyeung
Posting Yak Master

102 Posts

Posted - 2007-08-27 : 16:48:21
I tried to open a SQL Server 2005 Reporting Service report in ASP.Net 2.0 using ReportViewer. The following is my code.


Dim param(2) As Microsoft.Reporting.WebForms.ReportParameter
param(0) = New Microsoft.Reporting.WebForms.ReportParameter("ProjectID", Me.cboProject.SelectedValue)
param(1) = New Microsoft.Reporting.WebForms.ReportParameter("RunBy", Session("strEmployeeName"))
Me.ReportViewer1.ServerReport.SetParameters(param)

Me.ReportViewer1.ServerReport.ReportServerCredentials = New _
clsReportServerCredential(System.Configuration.ConfigurationManager.AppSettings("strReportViewUser"), _
System.Configuration.ConfigurationManager.AppSettings("strReportViewPassword")

Me.ReportViewer1.ServerReport.ReportServerUrl = New Uri(http://SQL2005/ReportServer/)
Me.ReportViewer1.ServerReport.ReportPath = "/nsPortalReports/rptIssuesByRole"
Me.ReportViewer1.ServerReport.Refresh()


I need help with passing multiple parameters. I got an erron on the second parameter (parm(1)). The error was

"Overload resolution failed because no accessible 'New' can be called without a narrowing conversion:
'Public Sub New(name As String, values() As String)': Argument matching parameter 'values' narrows from 'Object' to '1-dimensional array of String'.
'Public sub New(name As String, value As String)': Argument matching parameter 'value' narrow from 'Object' to 'String' "


How can I pass the parameters?

Thanks.
DanYeung

danyeung
Posting Yak Master

102 Posts

Posted - 2007-08-28 : 11:30:12
I figured it out and would like to share. I changed param(1) to use variable instead of session variable and it works. I don't understand but it works.

Dim RunBy as String = Session("strEmployeeName")
Dim param(1) As Microsoft.Reporting.WebForms.ReportParameter
param(0) = New Microsoft.Reporting.WebForms.ReportParameter("ProjectID", Me.cboProject.SelectedValue)
param(1) = New Microsoft.Reporting.WebForms.ReportParameter("RunBy", RunBy)
Me.ReportViewer1.ServerReport.SetParameters(param)

DanYeung
Go to Top of Page

jhermiz

3564 Posts

Posted - 2007-09-07 : 13:22:41
quote:
Originally posted by danyeung

I figured it out and would like to share. I changed param(1) to use variable instead of session variable and it works. I don't understand but it works.

Dim RunBy as String = Session("strEmployeeName")
Dim param(1) As Microsoft.Reporting.WebForms.ReportParameter
param(0) = New Microsoft.Reporting.WebForms.ReportParameter("ProjectID", Me.cboProject.SelectedValue)
param(1) = New Microsoft.Reporting.WebForms.ReportParameter("RunBy", RunBy)
Me.ReportViewer1.ServerReport.SetParameters(param)

DanYeung



Could be that your session times out, so it doesn't know who RunBy is or what its type is. WHen it times out you can get unexpected results or NULLS being passed. It wont like the null parameter.

Weblog -- [url]http://weblogs.sqlteam.com/jhermiz[/url]
Go to Top of Page

JimDavis1026
Starting Member

1 Post

Posted - 2010-03-01 : 18:14:28
After much consternation, I finally figured out the solution to this issue, however there must be some way to get around it.

If the value of the parameter does not appear in the list of values available to the report, then the ReportServer will return an error message stating that the parameter has a missing value. For instance, in a report that I just produced, I created a DropDownList with a list of agencies whose values are 1 through 6. However, in the report data, there were agencies with values 1 and 2, 3 through 6 were not in the available data.

So, when a user selected a value of 6 from the DropDownList, the ReportServer returned an error message "Parameter name 'AgencyId' is missing a value". What this means is that the value 6 is missing from the available values for the parameter in the report.

The error information is definitely lacking, but it is actually what the error means. I would expect there to be a message which I had already created which indicates there are No Rows available for the criteria that I entered. But at least I know what to do to work around the issue, now after 2 days of trying numerous suggestions, including this one.
Go to Top of Page
   

- Advertisement -