Share via


Crystal Report Parameter Issue in VS 2010 version 13.0.2000.0

Question

Friday, November 4, 2016 11:43 AM

Hi 

The below code is working fine in VS 2005 crystral report 10.2.3600.0

But the code is prompting to parameter in VS 2010 crystal report 13.0.2000.0

My aspx page

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

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<%@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.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>Untitled Page</title>
</head>


<body>
    
<form id="form1" runat="server">

       <asp:ScriptManager ID="ScriptManager1" runat="server"/>   
      
   
From <asp:TextBox ID="TxtFromDate" runat="server" Width="85px"  ValidationGroup="S"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TxtFromDate" Format="dd-MMM-yyyy" PopupPosition="BottomRight" ></cc1:CalendarExtender>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" SetFocusOnError="true" runat="server" ErrorMessage="*" ControlToValidate="TxtFromDate"
ForeColor="Red"   ValidationGroup="S"></asp:RequiredFieldValidator>

To <asp:TextBox ID="TxtToDate" runat="server" Width="85px"  ValidationGroup="S"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender3" runat="server" TargetControlID="TxtToDate" Format="dd-MMM-yyyy" PopupPosition="BottomRight" ></cc1:CalendarExtender>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" SetFocusOnError="true" runat="server" ErrorMessage="*" ControlToValidate="TxtToDate"
ForeColor="Red"   ValidationGroup="S"></asp:RequiredFieldValidator>

 <asp:Button ID="BtnSearch" runat="server" Text="Search"  ValidationGroup="S"  OnClick="BtnSearch_Click" />

<CR:CrystalReportViewer ID="CRRpt" runat="server" ReuseParameterValuesOnRefresh="true"   
ReportSourceID="CrystalReportSource1"  EnableDatabaseLogonPrompt="False" Height="600px" Width="1200px" BestFitPage="False"   />                                   
                  
<CR:CrystalReportSource ID="CrystalReportSource1" runat="server" >
<Report FileName="CRReport.rpt">
<Parameters>
                                        
<CR:ControlParameter ControlID="TxtFromDate" ConvertEmptyStringToNull="False" DefaultValue=""  PropertyName="Text"  />
<CR:ControlParameter ControlID="TxtToDate"   ConvertEmptyStringToNull="False" DefaultValue=""  PropertyName="Text"  />
                                            
</Parameters>
</Report>
</CR:CrystalReportSource>  




                

    </form>
        
    
</body>
</html>

CS File

using System;
using System.Data;
using System.Configuration;
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.Data.SqlClient;
using System.Collections.Specialized;
using System.Text;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

public partial class Report1 : System.Web.UI.Page
{
    ReportDocument crReportDocument = new ReportDocument();
    TableLogOnInfo crTableLogOnInfo = new TableLogOnInfo();
    ConnectionInfo crConnectionInfo = new ConnectionInfo();
    CrystalDecisions.CrystalReports.Engine.Database crDatabase;
    CrystalDecisions.CrystalReports.Engine.Tables crTables;

    protected void Page_Init(object sender, EventArgs e)
    {
        CRRpt.Visible = false;

        ReportDocument CRRpt1 = new ReportDocument();
        CRRpt1 = (ReportDocument)Session["A1"];
        CRRpt.ReportSource = CRRpt1;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
        }

    }

    protected void BtnSearch_Click(object sender, EventArgs e)
    {
        String strConnString = ConfigurationManager.ConnectionStrings["ALeatherERPString"].ConnectionString;
        SqlConnection con = new SqlConnection(strConnString);

        // Drum Report
        ReportDocument CRRpt1 = new ReportDocument();

        string Server12 = ConfigurationManager.AppSettings["Server"];
        string user = ConfigurationManager.AppSettings["Userid"];
        string Password = ConfigurationManager.AppSettings["Password"];
        string DataBase12 = ConfigurationManager.AppSettings["DataBase"];

        CRRpt1.Load(Server.MapPath("CRReport.rpt"));

        CRRpt1.SetParameterValue("fd", TxtFromDate.Text);
        CRRpt1.SetParameterValue("td", TxtToDate.Text);


        Session["A1"] = CRRpt1;

        crConnectionInfo.ServerName = Server12;
        crConnectionInfo.DatabaseName = DataBase12;
        crConnectionInfo.IntegratedSecurity = false;
        crConnectionInfo.UserID = user;
        crConnectionInfo.Password = Password;

        crDatabase = CRRpt1.Database;
        crTables = crDatabase.Tables;

        foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
        {
            crTableLogOnInfo = crTable.LogOnInfo;
            crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
            crTable.ApplyLogOnInfo(crTableLogOnInfo);
        }

        CRRpt.ReportSource = CRRpt1;
        CRRpt.RefreshReport();
        CRRpt.Visible = true;




    }
}

I have used Stored Procedure to get data from database using crystal report dataexpert in the add command i  have added the store

the code is below

DECLARE @fd Date
DECLARE @td Date

SET @fd ='{?fd}'
SET @td ='{?td}'

Exec LedgerRpt
@fd,@td

My question is the above code is working fine in VS 2005 version 10.2.3600.0

But in VS 2010 version 13.0.2000.0 ;  it is prompting for parameter though i have passed parameter in code behind.

All replies (1)

Tuesday, November 8, 2016 4:08 AM

The report is working fine in both VS 2005 and VS 2010.

But in VS 2010 with crystal report 13, it is prompting for parameter which i have already passed in code behind.

But in VS 2005 with crystal report 10.2.3600.0 the above same code is working fine and does not asking for parameter.

I hope its clear now

I found the thread

http://stackoverflow.com/questions/12034859/crystal-reports-keeps-prompting-for-parameter

But didn't understand where to change my code?