cancel
Showing results for 
Search instead for 
Did you mean: 

Report.SetParameterValue( , ) question

Former Member
0 Kudos

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>

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

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

myCrystalReportViewer1.ReportSource = myReportDocument;

Regards,

AG.

Answers (3)

Answers (3)

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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