Skip to Content
author's profile photo Former Member
Former Member

Report.SetParameterValue( , ) question

I bought one more book and followed an example for .NET coding.

I do not want the parameter prompting screen to come up and I have a parameter value stored in a session variable that I am trying to use as the "value" in the following method from the book.

SetParameterValue(name as String, val as Object) that is used to set the parameter by name method.

But now when clicking to view the report, nothing comes up at all, not even an error message, no viewer frame or anything. Can anyone spot anything wrong here???

Should the name of the parameter be exactly like the name inside the actual report, of which I did. What haven't I set or missed?

thanks,

SMA

-


   private void Page_Init(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string revid;
            revid = (string)Request.QueryString["ID"];
            Session["revid"] = revid;
            s_review_nbr = (string)Session["revid"];

            Int32 i_review_nbr = 0;
            bool isNum = false;
        isNum = Int32.TryParse((string)s_review_nbr, out i_review_nbr);
        if (isNum)
        {
            review_nbr = Convert.ToInt32(s_review_nbr);         
        } 
        ConfigureCrystalReports();
       }
    }  

private void ConfigureCrystalReports()
    {  
     .
     . Set my database connection stuff up hereu2026
     .
     .

    myReportDocument = new ReportDocument();
        string reportPath = Server.MapPath("Rev_Cat_Question_Completion2.rpt");
      myReportDocument.Load(reportPath);

                     myReportDocument.SetParameterValue("MyReviewNbr", review_nbr);
                      SetDBLogonForReport(connectionInfo, myReportDocument);  

    myCrystalReportViewer1.ReportSource = myReportDocument;
        
    }
private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument myReportDocument)
    {
        Tables tables = myReportDocument.Database.Tables;
        foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
        {
            TableLogOnInfo tableLogonInfo = table.LogOnInfo;
            tableLogonInfo.ConnectionInfo = connectionInfo;
            table.ApplyLogOnInfo(tableLogonInfo);

        }
    } 

-


This is what is in the client/design part of the page

<div style="background-color: #999966">

<CR:CrystalReportViewer ID="myCrystalReportViewer1" runat="server"

AutoDataBind="true" EnableDatabaseLogonPrompt="False" HasDrillUpButton="False"

Height="50px" Style="position: relative" ToolbarStyle-BorderColor="#660033"

Width="350px" EnableParameterPrompt="False" EnableDrillDown="False" /> </div>

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 23, 2009 at 09:51 PM

    Hi,

    Can you try putting the following code outside the IsPostBack method?

    myCrystalReportViewer1.ReportSource = myReportDocument;

    Regards,

    AG.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 23, 2009 at 10:52 PM

    Oh thank you so much.... I just didn't see it.

    It didn't solve the problem of passing the parameter, but it did bring back the report viewer display.

    I can't seem to get the parameter value from the point of configure crystal .... to the report viewer selection filter.

    Anybody have a similar problem?? The review_nbr fieldname is defined at top of page where is is a constant and should be local to the entire page. I think my problem is that I haven't seen in any examples what is done within the report template design.

    thanks again for getting me unstuck.

    SMA

    Edited by: Shawn Austin on Feb 23, 2009 2:53 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 23, 2009 at 11:03 PM

    Hi,

    You need to pass the connection information first and then load the report and then pass the parameters.

    Also are you not getting to the Configure Crystal method at the first run also? Is so then please check the session values. If its happening on next run then please have a look at the previously said approach and the post back method.

    [Samples|https://www.sdn.sap.com/irj/boc/samples?rid=/webcontent/uuid/80774579-b086-2b10-db91-ed58c4dda375] [original link is broken]; to help you.

    Regards,

    AG.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2009 at 09:03 PM

    I am not able to reply to others still commenting in this thread

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.