ReportViewer input parameter not working

Discussion in 'ASP.NET 2.0' started by MHCD, Sep 20, 2007.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I'm having a problem with the ReportViewer control
    at DASP not rendering anything when a report has an input parameter.

    I have two virtually identical reports:
    a team list that works--it has no input parameter,
    and team list that doesn't work--it prompts for a team number as input.

    These two are the same report, except that I added an input
    parameter of team number and a WHERE clause to the second
    report to select just the team number that the user
    enters as the input parameter.

    The report without an input parameter runscorrectly and
    displays all rows of the teams table.

    The report with an input param fails silently. It doesn't
    render anything at all after you enter the parameter and click
    on "View Report", although it does momentarily create a blue
    progress bar in the bottom of the browser and then it clears
    the parameter input box. It doesn't draw
    a report header, footer or anything.

    Running reports works fine using the ReportViewer
    control on our report server in-house, so I am used
    to doing reports this way, and had expected
    to run them the same way at DASP.

    Do any of you run reports at DASP using a ReportViewer
    and prompt the user for input parameters? Does it work?

    I created a support ticket for this. The reply was
    basically that though they provide the ReportViewer
    control at DASP, they don't actually support it,
    and suggested I post my question in the forum.

    Regards,
    Michael Hester
     
  2. Bruce

    Bruce DiscountASP.NET Staff

  3. Uh, I don't know what there is that might be relevant to post. I don't want to post my web.config file with my connection strings in it.


    Please understand that this is just a tiny test report. It runs correctly when I deploy it to my report server here at MHCD.


    The ReportViewer prompts for an input parameter ( a team number), you enter it, and it then retrieves the one team record from the table. My test data at DASP has teams 1,2, and 3 in it. I don't believe a simpler SQL report could even be written.


    All I am reporting is that report server sql2k501 at DASP is apparently not honoring input parameters for the ReportViewer--at least when I run the report using *my* ReportViewerPage. I suppose I could post the C# code for that page.The code for the pagecame from the Code Project article by DDarren as I recall. Nothing secret or special about it. I suppose I can post that code in a separate reply. I can also try "handing off" my report to your demo report viewer page (assuming I can find the name of it in my notes), and see ifusing an input parameterwill work that way.


    I provided instructionsfor logging on and trying the input parameterin support ticket# 873926. I don't know whether Frank actually tried it or not, since he didn't say.
     
  4. Okay, interesting development. I temporarily redirected my reports menuweb page to hand off the chosen report to the DASP "generic" ReportViewer page (named: "ReportViewer.aspx" on the sql2k501 server).


    It prompted me for team number, then ran the test report correctly! So, there *is* some difference between my ReportViewer web page and the one at DASP.


    My ReportViewer web page is written in C#as a "code-behind" page. Does a lot more set up than I expected now that I really examine it.


    As a work-around at least, I could move a lot of my setup code out of my ReportViewer page and place it further upstream in my reports menu page, then just hand off to the DASP report viewer page. I don't really care, as long as I can run reports and can rely on the DASP "ReportViewer.aspx" page always being available out there.


    Perhaps DASP would consider putting the codefor their report viewer page in the knowledge base so that I could compare my code against it? As I've said, my report viewer page partially works now--for reports that don't require input parameters.
     
  5. Here's the code for my ReportViewerPage.aspx file:


    To reiterate:this runs for reports without params, but doesn't handle input parameters correctly.


    <%@ Page Language="C#" Theme="RMReportViewerTheme" AutoEventWireup="true" CodeFile="ReportsViewerPage.aspx.cs" Inherits="ReportsViewerPage" %>


    <!-- Note that this page has a separate theme: RMReportViewerTheme, which has a white background, -->


    <!-- since the ReportViewer window also has a white background. Blue just looked terrible. -->


    <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"


    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


    <html xmlns="http://www.w3.org/1999/xhtml" >


    <head runat="server">


    <title>Reports Viewer Page</title>


    </head>


    <!-- the body tag modifications below are specific to this page being a report viewer application. -->





    <form id="reportform" runat="server">


    <table style="vertical-align: bottom; border-width: 0px; margin-top: 0px; margin-bottom: 0px; width: 100%; height: 100%; padding: 0px,0px,0px,0px;" cellspacing="0" cellpadding="0">


    <tr>


    <td style="height: 22px">


    <asp:Label ID="viewerPageForLabel" runat="server" Text="Report Viewer Page for:"


    Width="204px"></asp:Label>


    <asp:Label ID="reportDescriptionLabel" runat="server" Width="409px"></asp:Label>


    </td></tr>


    <tr>


    <td>


    <asp:Label ID="hintLabel" runat="server" Text="Use the back arrow on your browser to return to the Reports Menu"


    Width="617px"></asp:Label>


    </td>


    </tr>


    <tr>


    <td style="height: 100%;">


    &amp;nbsp;


    <%-- This is where the ReportViewer control will go. --%>


    <rsweb:ReportViewer ID="ReportViewer1" runat = "server" Font-Names="Verdana" Font-Size="8pt"


    Height="100%" ProcessingMode="Remote" Width="100%" Visible="true">


    </rsweb:ReportViewer>





    </td>


    </tr>


    </table>


    </form>


    </body>


    </html>
     
  6. I tried using a parameterized report with the report viewer control and it works fine :

    See :http://daspstaff00.web120.discountasp.net/Report/default.aspx (Instructions are the same as for rendering non parameterized report.Only difference is with the creation of the report) . Are you able to view the parameterized report in the Report manager after uploading it?

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  7. I'm afraid I don't understand your question. We have a Report Manager?

    I upload my report to the "sql2k501" server directly from my Visual Studio. The onlyoption that I know about is to then run the report.

    If there is a "Report Manager" capability on the control panel somewhere I haveyet to find it.

    I intend to clean uptheC# source code for my ReportViewer page that does not handle parameterized input and then I will post it.
     
  8. Here's the C# code of my Report Viewer webpage. Again, it works for non-parameterized reports, but just "wiffs" right through when an input parameter is prompted for. Perhaps this is some sort of "post back" issue?


    using System;


    using System.Data;


    using System.Configuration;


    using System.Net;


    using System.Security.Principal;


    using System.Collections;


    using System.Web;


    using System.Web.Security;


    using System.Web.UI;


    using System.Web.UI.WebControls;


    using System.Web.UI.WebControls.WebParts;


    using System.Web.UI.HtmlControls;


    using System.Web.Configuration;


    using System.Data.SqlClient;


    using Microsoft.Reporting.WebForms;


    public partial class ReportsViewerPage : System.Web.UI.Page


    {


    public string strReportChosen;


    public string strReportDescription;


    public string strReportSubdirectory;


    public string username;


    public string strUserFullName;


    public string strStaffId;


    public string connectionstring;


    public string str_cl_id; // for testing


    public string str_report_password; // for testing


    public string str_team_number; // for testing


    public int iTeam_Number; // for testing


    [Serializable]


    public sealed class MyReportServerCredentials :


    IReportServerCredentials


    {


    public WindowsIdentity ImpersonationUser


    {


    get


    {


    // Use the default Windows user. Credentials will be


    // provided by the NetworkCredentials property.


    return null;


    }


    }


    public ICredentials NetworkCredentials


    {


    get


    {


    // Read the user information from the Web.config file.


    // By reading the information on demand instead of


    // storing it, the credentials will not be stored in


    // session, reducing the vulnerable surface area to the


    // Web.config file, which can be secured with an ACL.


    // User name


    string userName =


    ConfigurationManager.AppSettings


    ["MyReportViewerUser"];


    if (string.IsNullOrEmpty(userName))


    throw new Exception(


    "Missing user name from web.config file");


    // Password


    string password =


    ConfigurationManager.AppSettings


    ["MyReportViewerPassword"];


    if (string.IsNullOrEmpty(password))


    throw new Exception(


    "Missing password from web.config file");


    // Domain


    string domain =


    ConfigurationManager.AppSettings


    ["MyReportViewerDomain"];


    if (string.IsNullOrEmpty(domain))


    throw new Exception(


    "Missing domain from web.config file");


    return new NetworkCredential(userName, password, domain);


    }


    }


    public bool GetFormsCredentials(out Cookie authCookie,


    out string userName, out string password,


    out string authority)


    {


    authCookie = null;


    userName = null;


    password = null;


    authority = null;


    // Not using form credentials


    return false;


    }


    }


    protected void Page_Init(object sender, EventArgs e)


    {


    ReportViewer1.ServerReport.ReportServerCredentials =


    new MyReportServerCredentials();


    }


    private void GetBack()


    {


    if (this.ReportViewer1.ServerReport.IsDrillthroughReport)


    {


    this.ReportViewer1.PerformBack();


    GetBack(); // recursive call to itself...


    }


    }


    protected void Page_Load(object sender, EventArgs e)


    {


    strReportChosen = Session["reportname"].ToString();


    strReportDescription = Session["reportdescription"].ToString();


    strReportSubdirectory = Session["reportsubdirectory"].ToString();


    strUserFullName = Session["fullname"].ToString();


    username = Session["username"].ToString();


    // get the staff_id number out of the session area


    strStaffId = Session["staff_id"].ToString();


    reportDescriptionLabel.Text = strReportDescription;


    // try moving the report server credentials here to see if it will work...


    this.ReportViewer1.ServerReport.ReportServerCredentials =


    new MyReportServerCredentials();


    this.ReportViewer1.ServerReport.ReportServerUrl = new System.Uri("https://rs2k501.discountasp.net/ReportServer");


    this.ReportViewer1.ServerReport.ReportPath = "/mhcdrecover/reports/" + strReportChosen;


    }





    }
     
  9. Reporting Service Manager in the control panel here

    See the first option here and see if are able to view the reports in the Report Manager interface .

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  10. I'm finally seeing what you guys are talking about about a "Report Manager",
    but realize that we aren't communicating very well.


    I wasn't aware that I was supposed to click on the "Report Server URL" link on
    that page of the control panel and that it would actually take me tosomething
    useful (nor is that mentioned anywhere in documentation that I can recall).


    So now, for the very first time, I see that there are ways to set various properties for
    folders, individual reports, and so forth. Good to know.


    I also see that the expectation is that reports can be run by starting
    them from the reports folder.


    But--the crux of the matter--is that we don't use the regular reports folder
    way of displaying reports at MHCD. We can't.


    Our users log in individually on a web page. Their user record sets their
    "role" and a list of "teams allowed" of data that they are permitted to view.


    The reports menu web page then writes a "ReportRequest" record--which
    partially functions as a log of reports that were chosen, and it also contains
    the user's current sessionid string.


    The reports menu page also writes a very temporary set of "teams requested"
    records into another table. I join the two tables on sessionid and use the
    SQL IDENT_CURRENT function as a tie-breaker to deal with concurrency issues.
    You see, several people might be requesting the same report at exactly the
    same time, but have vastly different ranges of data that they are permitted
    to view. This technique works for keeping collisions from occuring and
    showing sensitive information to users that they are not supposed to see.


    The web pages have code that deletes or disables these request
    records after they have been used. All of this depends on being able to
    access a Microsoft ReportViewer control *somewhere* to display the report once
    all of the proper data has finally been assembled.


    The generic reports folder page that shows links to each report is worthless
    to us because of the intimate nature between the web pages and the reports
    themselves. Our reports come up empty (showing only page headers and footers)
    if people try to run them directly from the reports folder by clicking on
    the linked name of the report. Only by going through all of the required
    web pages does a user get to actually see any information on a report.


    For the moment I am "detouring" from my reports menu webpage to using the DASP
    ReportViewer.aspx webpage instead--since this works for parameterized input--although the extra prompting for username and password of the report server is a bit of a nuisance.


    I realize that the Report Server Credentials code might
    take care of that issue. It worked on my personally-coded ReportViewer
    page, but doesn't seem to work in this context.

    But as long as the DASP report viewer page is available to me I could be satisfied
    with using it for now.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page