Parameter Passing to SQL report using URL

  • hey guys i am using the asp .net web app to show the reports in the site.

    i am using the report viewer control for this purpose.

    my report that is built using the BI studio is taking one parameter and thus shows relevant results.

    in my web app ... my 1st page is login page ... in which i check the territory id field if valid or not

    and if it is valid it should show Report2.aspx page with the result set in the reportviewer control.

    So in short i am wanna pass the value "territory id " field from that text box into the report page

    as the parameter for the report.

    This i want to do by passing the URL string and thus report is finally gonna use that string to

    display the result.

    please let me know the steps to do this and also detailed description if u can.

    as i am new to SSRS and making reports work ... 🙂

    Thanks in advance.

    DEVAM

  • No one can accurately answer this question without seeing the code you are using. If you post some code we can help.

    With the limited information you are giving I can guess that your url string to the report page is something like this:

    http://reportpage.aspx?territoryid=1

    So in the Page_Load event of your report page you would need to do something like this (VB.NET):

    Private mintTerritoryID as Integer

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If Not Page.IsPostBack Then

    mintTerritoryId = Request("TerritoryID")

    End If

    RunReport()

    End Sub

    Private Sub RunReport()

    Dim sReportServerURL As String = "http://LocalHost/ReportServer"

    Dim sReportPath As String = "/DemoReports/DemoReport"

    Dim Param As Microsoft.Reporting.WebForms.ReportParameter() = {New Microsoft.Reporting.WebForms.ReportParameter("lname", mintTerritoryId)}

    ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote

    ReportViewer1.ServerReport.ReportServerUrl = New Uri(sReportServerURL)

    ReportViewer1.ServerReport.ReportPath = sReportPath

    ReportViewer1.ServerReport.SetParameters(Param)

    ReportViewer1.ShowParameterPrompts = False

    ReportViewer1.ShowPromptAreaButton = False

    ReportViewer1.ServerReport.Refresh()

    ReportViewer1.Visible = True

    End Sub

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply