Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using VS2005 and IE8, now I have a problem in printing of crystal report in IE8.
please give me the solution. The problem is ..when i clicked on print option a crystal report viewer window came and it was loading for several minutes. But no output came just loading was going on..

Edit - [ Moved OP's code from comment section. ]
C#
CrystalDecisions.CrystalReports.Engine.Tables tables = rpt.Database.Tables; 
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables) 
{ 
CrystalDecisions.Shared.TableLogOnInfo tableLogOnInfo = table.LogOnInfo; 
tableLogOnInfo.ConnectionInfo.ServerName = ConfigurationManager.AppSettings["CrystalServer"]; tableLogOnInfo.ConnectionInfo.DatabaseName = ConfigurationManager.AppSettings["DatabaseName"]; tableLogOnInfo.ConnectionInfo.UserID = ConfigurationManager.AppSettings["CrystalUser"]; tableLogOnInfo.ConnectionInfo.Password = ConfigurationManager.AppSettings["CrystalPassword"]; table.ApplyLogOnInfo(tableLogOnInfo); } rpt.Refresh(); CrystalReportViewer1.ReportSource = rpt;
Posted
Updated 26-Dec-11 20:17pm
v3
Comments
Sergey Alexandrovich Kryukov 27-Dec-11 0:56am    
What problem? Don't ask with reply, use "Improve question" above.
--SA
Al Moje 27-Dec-11 0:56am    
What particular printing problem are you encountering, share us your code...
Mousumi2708 27-Dec-11 1:35am    
CrystalDecisions.CrystalReports.Engine.Tables tables = rpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{

CrystalDecisions.Shared.TableLogOnInfo tableLogOnInfo = table.LogOnInfo;
tableLogOnInfo.ConnectionInfo.ServerName = ConfigurationManager.AppSettings["CrystalServer"];
tableLogOnInfo.ConnectionInfo.DatabaseName = ConfigurationManager.AppSettings["DatabaseName"];
tableLogOnInfo.ConnectionInfo.UserID = ConfigurationManager.AppSettings["CrystalUser"];
tableLogOnInfo.ConnectionInfo.Password = ConfigurationManager.AppSettings["CrystalPassword"];

table.ApplyLogOnInfo(tableLogOnInfo);
}
rpt.Refresh();
CrystalReportViewer1.ReportSource = rpt;

1 solution

Hi,

See this coding if could help...

Example:

In code behind:
C#
 using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data;
using XP.Tools;

public partial class Report1 : System.Web.UI.Page
{
    #region "Declaration Report Document and DataSet"
    ReportDocument crpt = new ReportDocument();
    string rptLoc = String.Empty;
    // Assumed Dataset1 has already created in App_Code with its fields
    DataSet1 ds = new DataSet1();
    #endregion

    #region "Methods for Adding a parameters"
    private void AddParameter(ReportDocument reportDocument, string value, string parameterName)
    {
        ParameterFieldDefinitions prmDef = reportDocument.DataDefinition.ParameterFields;
        ParameterValues prmVal = new ParameterValues();
        ParameterDiscreteValue prmDiscreteVal = new ParameterDiscreteValue();
        prmDiscreteVal.Value = value;
        prmVal.Add(prmDiscreteVal);
        ParameterFieldDefinition prmFD = prmDef[parameterName];
        try
        {
            prmFD.ApplyCurrentValues(prmVal);
            prmFD.ApplyDefaultValues(prmVal);
        }
        catch (Exception)
        {
            Response.Redirect("~\\Login.aspx");
        }
    }
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        CrystalReportViewer1.ReportSourceID = "CrystalReportSource1";
        CrystalReportSource1.Report.FileName = Server.MapPath("") + "\\CReport\\ClaimStatementIP.rpt";
        rptLoc = CrystalReportSource1.Report.FileName;
        crpt.Load(rptLoc);
        crpt.SetDataSource(ds);
        AddParameter(crpt, "Client Card Number", "CardNumber");
        AddParameter(crpt, "Client Policy Number", "PolicyOwner");
        DataTable dt = new DataTable();
        dt = GetBenefits();  // Get Benefits from database table 
        ds.dtCPT.Clear();
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow row;
                row = ds.dtCPT.NewRow();
                row["Description"] = dt.Rows[i]["Description"];
                row["ActualCharges"] = dt.Rows[i]["ActualCharges"];
                ds.dtCPT.Rows.Add(row);  // the name of table in DataSet1 is 'dtCPT'
            }
            CrystalReportViewer1.ReportSource = crpt;
        }

    }

    private DataTable GetBenefits()
    {
        DataTable dt = new DataTable();
        // Some code to retieve records here from database
        // ....
        return dt;
    }
}



Hope this could help...

Regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900