Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem passing parameters to report.

Status
Not open for further replies.

jjjax64

IS-IT--Management
Apr 27, 2010
39
US
We have a 2008 ssrs report that runs fine while in reporting services. It has a dataset that calls an sql sp with 3 parameters. I have defined 3 paramters in reporting service and put in default values and have my dataset pointing to these parameters and report opens fine. The problem that I have is when is aspx page and using report viewer control, it doesn't work with parameters. If I run report without parameters, it works so my connections and so on should be good. When I run with parameters, I get the following message:
Parameter validation failed. It is not possible to provide valid values for all parameters. (rsParameterError)
Here is the code from aspx page that I am having the problem with.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Me.ReportViewer1.ServerReport.ReportPath = "/customerreports/report3"
Me.ReportViewer1.ServerReport.ReportPath = "/customerreports/rptupltest"
Dim params(3) As Microsoft.Reporting.WebForms.ReportParameter
params(0) = New Microsoft.Reporting.WebForms.ReportParameter("Customer", "970000")
params(1) = New Microsoft.Reporting.WebForms.ReportParameter("Facility", "01")
params(2) = New Microsoft.Reporting.WebForms.ReportParameter("Commodity", "116")
Me.ReportViewer1.ServerReport.SetParameters(params)
Me.ReportViewer1.ServerReport.Refresh()
Dim result As Byte()
Dim warnings As Microsoft.Reporting.WebForms.Warning() = Nothing
Dim DeviceInfo As String = "<DeviceInfo>" & " <OutputFormat>PDF</OutputFormat>" & "</DeviceInfo>"
' Dim DeviceInfo As String = "<DeviceInfo>" & " <OutputFormat>PDF</OutputFormat>" & " <PageWidth>11in</PageWidth>" & " <PageHeight>8.5in</PageHeight>" & " <MarginTop>0.1in</MarginTop>" & " <MarginLeft>0.1in</MarginLeft>" & " <MarginRight>0.1in</MarginRight>" & " <MarginBottom>0.1in</MarginBottom>" & "</DeviceInfo>"
Dim streamIDs As String() = Nothing
Dim mimeType As String = "application/PDF"
Dim encoding As String = Nothing
Dim extension As String = Nothing
'Render report in PDF format
result = Me.ReportViewer1.ServerReport.Render("PDF", DeviceInfo, mimeType, encoding, extension, streamIDs, warnings)
Response.ClearContent()
Response.ContentType = mimeType
Response.AddHeader("content-disposition", "attachment; filename=Report." & extension)
Response.BinaryWrite(result)
Response.End()
End Sub


I've been working and searching for information on this for hours and no luck yet.

Thanks,
Joe
 
Update, looks like I got it. Here is my code in case anyone comes across it in the future.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.ReportViewer1.ServerReport.ReportPath = "/customerreports/rptupltest"
Dim Customer As New ReportParameter()
Customer.Name = "Customer"
Customer.Values.Add("970029")
Dim Facility As New ReportParameter()
Facility.Name = "Facility"
Facility.Values.Add("03")
Dim Commodity As New ReportParameter()
Commodity.Name = "Commodity"
Commodity.Values.Add("340")
Dim parameters() As ReportParameter = {Customer, Facility, Commodity}
Me.ReportViewer1.ServerReport.SetParameters(parameters)
Dim result As Byte()
Dim warnings As Microsoft.Reporting.WebForms.Warning() = Nothing
Dim DeviceInfo As String = "<DeviceInfo>" & " <OutputFormat>PDF</OutputFormat>" & "</DeviceInfo>"
'Dim DeviceInfo As String = "<DeviceInfo>" & " <OutputFormat>PDF</OutputFormat>" & " <PageWidth>11in</PageWidth>" & " <PageHeight>8.5in</PageHeight>" & " <MarginTop>0.1in</MarginTop>" & " <MarginLeft>0.1in</MarginLeft>" & " <MarginRight>0.1in</MarginRight>" & " <MarginBottom>0.1in</MarginBottom>" & "</DeviceInfo>"
Dim streamIDs As String() = Nothing
Dim mimeType As String = "application/PDF"
Dim encoding As String = Nothing
Dim extension As String = Nothing
'Render report in PDF format
result = Me.ReportViewer1.ServerReport.Render("PDF", DeviceInfo, mimeType, encoding, extension, streamIDs, warnings)
Response.ClearContent()
Response.ContentType = mimeType
Response.AddHeader("content-disposition", "attachment; filename=Report." & extension)
Response.BinaryWrite(result)
Response.End()
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top