1 Replies - 10339 Views - Last Post: 26 January 2012 - 08:26 AM Rate Topic: -----

#1 Blasterman007  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 41
  • Joined: 15-September 09

Passing Parameters to ReportViewer Not Working, No Errors

Posted 25 January 2012 - 01:01 PM

I am new to ReportViewer. I got it to work perfectly when my data source was a view. I have built a stored procedure so I can pass three values and dynamically change the report based on Location, a start date and an end date.

I have added the stored procedure as a data source (see attached text file for coding). Using the wizard, I tested it by setting values for each parameter and it returned results (see attached snapshot). Note: All data is test data and is not true.

I went into the report and specified the parameters (see attached snapshot).

In the ASP page, I added some code I found via blogs/google for passing parameters to reportviewer using VB Script. I was going to upload the page as a file but the attach keeps failing so I am putting the asp page code below.

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="rptAvgDailyPatients.aspx.vb" Inherits="AKSMReporting.rptAvgDailyPatients" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server" language="vbscript" type="text/vbscript">
    Sub cmdRunReport_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdRunReport.Click
        Dim reportparam0 As Integer = sLoc.Value
        Dim reportparam1 As Date = sDate.Value
        Dim reportparam2 As Date = eDate.Value
        
        Dim p(2) As ReportParameter
        p(0) = New ReportParameter("Loc", reportparam0)
        p(1) = New ReportParameter("sDate", reportparam1)
        p(2) = New ReportParameter("eDate", reportparam2)
        rvAvgDailyPat.LocalReport.SetParameters(p)
        rvAvgDailyPat.LocalReport.Refresh()
    End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Oncology - Avg Daily Patients Report</title>
</head>

<body>
    <form id="frmAvgDailyPatients" runat="server" action="rptAvgDailyPatients.aspx" method="post" >
    <div align="center">
        <table cellspacing="0" cellpadding="0" border="0" width="900">
            <tr>
                <td align="center">Location:</td>            
                <td><input type="text" name="sLoc" id="sLoc" value="1" runat="server" /></td>
                <td align="center">Start Date:</td>            
                <td><input type="text" name="sDate" id="sDate" value="1/1/2011" runat="server" /></td>
                <td align="center">End Date:</td>            
                <td><input type="text" name="eDate" id="eDate" value="12/1/2011" runat="server" /></td>
                <td align="center"><asp:Button ID="cmdRunReport" runat="server" Text="Run Report" /></td>
            </tr>        
            <tr><td colspan="7">&nbsp;</td></tr>
        </table>
    </div>
    <div align="center">
        <rsweb:ReportViewer ID="rvAvgDailyPat" runat="server" Font-Names="Tahoma" 
            Font-Size="10pt" forecolor="white" Height="8in" Width="11in" BackColor="#003366" 
            Font-Bold="True" LinkActiveColor="White" LinkActiveHoverColor="White" 
            LinkDisabledColor="LightGray">
            <LocalReport ReportPath="rptAvgDailyPatients.rdlc">
                <DataSources>
                    <rsweb:ReportDataSource DataSourceId="dsAvgDailyPatients" 
                        Name="qryAvgDailyPat_spAvgDailyPatients" />
                </DataSources>
            </LocalReport>
        </rsweb:ReportViewer>
        <asp:ObjectDataSource ID="dsAvgDailyPatients" runat="server" 
            SelectMethod="GetData" 
            TypeName="AKSMReporting.qryAvgDailyPatTableAdapters.spAvgDailyPatientsTableAdapter">
        </asp:ObjectDataSource>
    </div>
    </form>
</body>
</html>



When I debug the page locally, I just see the three inputs and the button. I set default values to the inputs for my ease. When I press the button, it appears to run code (I see a process bar clocking at the bottom), but the report does not appear.

Anybody have some ideas as to why this is not working or have a better suggestion for approach/execution? Also, if anyone has any suggestions to a good resource book or website for VBScript against MS ReportViewer, I would really appreciate it. If I get this working, my bosses want me to do a lot in this.

Thx in advance for any assistance.

Attached image(s)

  • Attached Image
  • Attached Image

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: Passing Parameters to ReportViewer Not Working, No Errors

#2 Blasterman007  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 41
  • Joined: 15-September 09

Re: Passing Parameters to ReportViewer Not Working, No Errors

Posted 26 January 2012 - 08:26 AM

Been playing with it all night and I finally see an error:

Microsoft.Reporting.WebForms.LocalProcessingException was unhandled by user code
Message="An error occurred during local report processing."
Source="Microsoft.ReportViewer.WebForms"
StackTrace:
at Microsoft.Reporting.WebForms.LocalReport.SetParameters(IEnumerable`1 parameters) at ASP.rptavgdailypatients_aspx.cmdRunReport_Click(Object sender, EventArgs e) in C:\Users\dmoody\Documents\Visual Studio 2008\Projects\AKSMReporting\AKSMReporting\rptAvgDailyPatients.aspx:line 18 at System.Web.UI.WebControls.Button.onclick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException: System.NullReferenceException
Message="Object reference not set to an instance of an object."
Source="Microsoft.ReportViewer.Common"
StackTrace:
at Microsoft.ReportingServices.ReportProcessing.ParameterInfoCollection.Combine(ParameterInfoCollection oldParameters, ParameterInfoCollection newParameters, Boolean checkReadOnly, Boolean ignoreNewQueryParams, Boolean isParameterDefinitionUpdate, CultureInfo culture) at Microsoft.ReportingServices.ReportProcessing.ParameterInfoCollection.Combine(ParameterInfoCollection oldParameters, ParameterInfoCollection newParameters, Boolean checkReadOnly, Boolean ignoreNewQueryParams, Boolean isParameterDefinitionUpdate) at Microsoft.Reporting.LocalService.GetReportParameters(CatalogItemContext reportContext, NameValueCollection userSpecifiedValues, ParameterInfoCollection baseLineParameters, DatasourceCredentialsCollection credentials, ReportRuntimeSetup reportRuntimeSetup) at Microsoft.Reporting.WebForms.LocalReport.SetParameters(IEnumerable`1 parameters)
InnerException:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1