locked
Need help on Working with Parameters in SAP Crystal Report for Visual Studio RRS feed

  • Question

  • User-557095619 posted

    Hi,

    I'm in currently using SAP Crystal Report for Visual Studio, http://www.businessobjects.com/jump/xi/crvs2010/default.asp

    The problem is my working with parameters in not working

    My report name is SampleParam1.rpt. My parameter fields is p_EmployeeID. In Visual Studio (in Main Report Preview), It's Prompt for New Parameter values. Once parameters value is entered, the report is display properly

    Here is my code to display the SampleParam1.rpt using ASP.NET

    SampleParam1View.aspx

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="SampleParam1View.aspx.cs" Inherits="SampleParam1View" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
            Enter Employee ID:
            <asp:TextBox ID="txtEmployeeID" runat="server"></asp:TextBox>
    &nbsp;<asp:Button ID="btnView" runat="server" onclick="btnView_Click" Text="View" />
        
        </div>
        </form>
    </body>
    </html>

    SampleParam1View.aspx.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class SampleParam1View : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected void btnView_Click(object sender, EventArgs e)
        {
            Response.Redirect("SampleParam1View2.aspx?EmployeeID=" + txtEmployeeID.Text + "");
        }
    }

    SampleParam2View.aspx

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="SampleParam1View2.aspx.cs" Inherits="SampleParam1View2" %>
    
    <%@ Register assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
            <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" 
                AutoDataBind="true" />
        
        </div>
        </form>
    </body>
    </html>
    

    SampleParam2View.aspx.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using CrystalDecisions.Shared;
    
    public partial class SampleParam1View2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["EmployeeID"] != null)
                { BindReport(Request.QueryString["EmployeeID"]); }
    
            }
        }
    
        protected void BindReport(string EmployeeID)
        {
            ConnectionInfo ConnInfo = new ConnectionInfo();
            var _with1 = ConnInfo;
            _with1.ServerName = @"wkm1925-pc\wkm1925";
            _with1.DatabaseName = "Northwind";
            _with1.UserID = "crNorthwind";
            _with1.Password = "1925";
    
            CrystalReportViewer1.ParameterFieldInfo.Clear();
            if (EmployeeID.Length > 0)
            {
                //report with parameter
                CrystalReportViewer1.ReportSource = Server.MapPath("SampleParam1.rpt");
                ParameterFields paramFields = CrystalReportViewer1.ParameterFieldInfo;
                ParameterField p_EmpID = new ParameterField();
                p_EmpID.Name = "p_EmployeeID";
                ParameterDiscreteValue p_EmpID_Value = new ParameterDiscreteValue();
                p_EmpID_Value.Value = EmployeeID;
                p_EmpID.CurrentValues.Add(p_EmpID_Value);
                paramFields.Add(p_EmpID);            
            }
            else
            {
                //report without parameter
                CrystalReportViewer1.ReportSource = Server.MapPath("crGrouping1.rpt");
            }
    
            foreach (TableLogOnInfo cnInfo in this.CrystalReportViewer1.LogOnInfo)
            {
                cnInfo.ConnectionInfo = ConnInfo;
    
            }
    
            CrystalReportViewer1.RefreshReport();
        }
    }

    My problem is, SampleParam1.rpt did not capture value from ASP.NET page. It's prompt Crystal Report New Parameter values same as in Main Report Preview

    I'm stuck

    Sunday, June 5, 2011 4:57 AM

Answers

  • User-1694870838 posted

    Hi,

    is the p_EmployeeID your parameter? why the  p_EmployeeID  is a string in this clause: p_EmpID.Name = "p_EmployeeID" ?

    Best Regards

    From Damon

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 9, 2011 12:38 AM

All replies

  • User-1694870838 posted

    Hi,

    is the p_EmployeeID your parameter? why the  p_EmployeeID  is a string in this clause: p_EmpID.Name = "p_EmployeeID" ?

    Best Regards

    From Damon

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 9, 2011 12:38 AM
  • User-557095619 posted

    Hi,

    is the p_EmployeeID your parameter? why the  p_EmployeeID  is a string in this clause: p_EmpID.Name = "p_EmployeeID" ?

    Best Regards

    From Damon

    p_EmployeeID is a my parameter

    I dont know why the p_EmployeeID is a string in this clause: p_EmpID.Name = "p_EmployeeID"

     

    Thursday, August 18, 2011 2:41 AM