locked
Itz a Help Required Very urgent..... RRS feed

  • Question

  • User1152553138 posted

    Hi..

    I have one Crystal Report in aspx page with subreport binded on main Report in local itz working fine....

    But in Hosting itz shows this error:-

    This field name is not known. Error in File C:\WINDOWS\TEMP\Sales{B3FAD1D1-2967-427F-AED1-494144E1DF63}.rpt: Error in formula <costpersqft>. '{command.Qty}*{Sales.RatePerUnit}/{Sales.Total}' This field name is not known</costpersqft>


    Actually this code is from subreport '{command.Qty}*{Sales.RatePerUnit}/{Sales.Total}' formula field..  but itz actually not showing the main report  also... then the subreport im accessing.



    This is my CS File:- which im using normally to bind the crystal report


    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 CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    public partial class Update_AddDyeingChemRpt : System.Web.UI.Page
    {
        ReportDocument crReportDocument = new ReportDocument();
        //'CrystalReport1' must be the name the CrystalReport
        TableLogOnInfo crTableLogOnInfo = new TableLogOnInfo();
        ConnectionInfo crConnectionInfo = new ConnectionInfo();
        //Crystal Report Properties
        CrystalDecisions.CrystalReports.Engine.Database crDatabase;
        CrystalDecisions.CrystalReports.Engine.Tables crTables;
        CrystalDecisions.CrystalReports.Engine.Table crTable;
        protected void Page_Load(object sender, EventArgs e)
        {
            string Server1 = ConfigurationManager.AppSettings["Server"];
            string user = ConfigurationManager.AppSettings["Userid"];
            string Password = ConfigurationManager.AppSettings["Password"];
            string DataBase = ConfigurationManager.AppSettings["DataBase"];
            crReportDocument.Load(Server.MapPath("Update_AddDyeingChem.rpt"));
            crReportDocument.Load(Server.MapPath("CDyeingRpt.rpt"));
           // crReportDocument.SetParameterValue("I",TextBox1.Text,"CDyeingRpt.rpt");
            //rpt.SetParameterValue("[parameter name]", [value]);
            //crReportDocument.Subreports["CDyeingRpt.rpt"].SetParameterValue("I","B002");
    //        c.ReportDocument.Subreports(
    //"rptSub").SetParameterValue("key", "value") 
            crConnectionInfo.ServerName = Server1;
            crConnectionInfo.DatabaseName = DataBase;
            crConnectionInfo.IntegratedSecurity = false;
            crConnectionInfo.UserID = user;
            crConnectionInfo.Password = Password;
            crDatabase = crReportDocument.Database;
            crTables = crDatabase.Tables;
            foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
            {
                crTableLogOnInfo = crTable.LogOnInfo;
                crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                crTable.ApplyLogOnInfo(crTableLogOnInfo);
            }
            CrystalReportViewer1.ReportSource = crReportDocument;
            CrystalReportViewer1.Visible = true;
        }
    }

    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 CrystalDecisions.CrystalReports.Engine;

    using CrystalDecisions.Shared;


    public partial class Sales : 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;

        CrystalDecisions.CrystalReports.Engine.Table crTable;


        protected void Page_Load(object sender, EventArgs e)

        {

            string Server1 = ConfigurationManager.AppSettings["Server"];

            string user = ConfigurationManager.AppSettings["Userid"];

            string Password = ConfigurationManager.AppSettings["Password"];

            string DataBase = ConfigurationManager.AppSettings["DataBase"];

            crReportDocument.Load(Server.MapPath("Sales.rpt"));

            crConnectionInfo.ServerName = Server1;

            crConnectionInfo.DatabaseName = DataBase;

            crConnectionInfo.IntegratedSecurity = false;

            crConnectionInfo.UserID = user;

            crConnectionInfo.Password = Password;


            crDatabase = crReportDocument.Database;

            crTables = crDatabase.Tables;


            foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)

            {

                crTableLogOnInfo = crTable.LogOnInfo;

                crTableLogOnInfo.ConnectionInfo = crConnectionInfo;

                crTable.ApplyLogOnInfo(crTableLogOnInfo);

            }


            CrystalReportViewer1.ReportSource = crReportDocument;

            CrystalReportViewer1.Visible = true;

        }

    }

    My Subreport name is:"SalesHalf.rpt" 

    Plz Help me To Solve This very very very very urgent....



    Saturday, May 22, 2010 2:15 PM

All replies

  • User-25924017 posted

    The error indicates (not only) that there is somehow difference in database on your local and at hosting.

    if possible do a verify database on crystal report at hosting server (sound odd) but if possible otherwise try to run all your queries on server if they are working fine.


    Saturday, May 22, 2010 3:24 PM
  • User1152553138 posted

    In Local itz working would u plz let me know how to pass a parameter for subreport from the above cs file

    Sunday, May 23, 2010 1:28 AM
  • User-25924017 posted

    This is the way I do it, but parameter in subreport!!!, thats actully in main report, sub report uses that from main report.


    Here name is name of the parameter and value is Value for the same. I call below peace of code, for all the parameters in name value collection because I dont know what is coming in of what type so if you want simplyfy it but it generic code. Here I am using Cyrstal report source but you all directly loop on reportdocument.DataDefinition.ParameterFields.

           

    Protected void SetReportParameters(string name, string value)
    {
           ParameterValues parameterValue = new ParameterValues();
            ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
            CultureInfo Iformat = CultureInfo.CurrentCulture;
    
    for (int i = 0; i < CrystalReportSource.ReportDocument.DataDefinition.ParameterFields.Count; i++)
                {
                    if (CrystalReportSource.ReportDocument.DataDefinition.ParameterFields[i].Name == name)
                    {
    
    
                        switch (CrystalReportSource.ReportDocument.DataDefinition.ParameterFields[i].ValueType)
                        {
    
                            case FieldValueType.NumberField:
    
                                parameterDiscreteValue.Value = Convert.ToInt32(value);
                                parameterValue.Add(parameterDiscreteValue);
                                CrystalReportSource.ReportDocument.DataDefinition.ParameterFields[i].ApplyCurrentValues(parameterValue);
                                break;
                            case FieldValueType.CurrencyField:
    
                                parameterDiscreteValue.Value = Convert.ToDouble(value);
                                parameterValue.Add(parameterDiscreteValue);
                                CrystalReportSource.ReportDocument.DataDefinition.ParameterFields[i].ApplyCurrentValues(parameterValue);
                                break;
                            case FieldValueType.DateField:
    
                                parameterDiscreteValue.Value = Convert.ToDateTime(value, Iformat);
                                parameterValue.Add(parameterDiscreteValue);
                                CrystalReportSource.ReportDocument.DataDefinition.ParameterFields[i].ApplyCurrentValues(parameterValue);
                                break;
                            case FieldValueType.DateTimeField:
    
                                parameterDiscreteValue.Value = Convert.ToDateTime(value, Iformat);
                                parameterValue.Add(parameterDiscreteValue);
                                CrystalReportSource.ReportDocument.DataDefinition.ParameterFields[i].ApplyCurrentValues(parameterValue);
                                break;
                            case FieldValueType.BooleanField:
    
                                parameterDiscreteValue.Value = Convert.ToBoolean(value);
                                parameterValue.Add(parameterDiscreteValue);
                                CrystalReportSource.ReportDocument.DataDefinition.ParameterFields[i].ApplyCurrentValues(parameterValue);
                                break;
                            case FieldValueType.StringField:
    
                                parameterDiscreteValue.Value = Convert.ToString(value);
                                parameterValue.Add(parameterDiscreteValue);
                                CrystalReportSource.ReportDocument.DataDefinition.ParameterFields[i].ApplyCurrentValues(parameterValue);
                                break;
                        }
                    }
                }
    }
    Sunday, May 23, 2010 5:34 AM
  • User1152553138 posted

    Thanx ....

    My Above Code is use to call the report ....

    Plz Explain Your Code For Example If u have main Report name:Abc.rpt and subreport name is edf.rpt...

    how to pass abc.rpt filedname as parameter to subreport edf.rpt fields....

    itz very urgent reply needed

    Sunday, May 23, 2010 6:17 AM
  • User-25924017 posted

    Thats  done in report itself, please follow this thread and follow the steps and then either use above code for looping through all the parameter fileds and applying parameter value or use the report.setparameter function for fewer parameters.

    http://forums.asp.net/t/1212579.aspx


    Sunday, May 23, 2010 6:25 AM
  • User1152553138 posted

    This is my 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 CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    public partial class Update_AddDyeingChemRpt : System.Web.UI.Page
    {
        ReportDocument crReportDocument = new ReportDocument();
        //'CrystalReport1' must be the name the CrystalReport
        TableLogOnInfo crTableLogOnInfo = new TableLogOnInfo();
        ConnectionInfo crConnectionInfo = new ConnectionInfo();
        //Crystal Report Properties
        CrystalDecisions.CrystalReports.Engine.Database crDatabase;
        CrystalDecisions.CrystalReports.Engine.Tables crTables;
        CrystalDecisions.CrystalReports.Engine.Table crTable;
        protected void Page_Load(object sender, EventArgs e)
        {
            string Server1 = ConfigurationManager.AppSettings["Server"];
            string user = ConfigurationManager.AppSettings["Userid"];
            string Password = ConfigurationManager.AppSettings["Password"];
            string DataBase = ConfigurationManager.AppSettings["DataBase"];
            crReportDocument.Load(Server.MapPath("Update_AddDyeingChem.rpt"));
            crReportDocument.Load(Server.MapPath("CDyeingRpt.rpt"));
           // crReportDocument.SetParameterValue("I",TextBox1.Text,"CDyeingRpt.rpt");
            //rpt.SetParameterValue("[parameter name]", [value]);
            //crReportDocument.Subreports["CDyeingRpt.rpt"].SetParameterValue("I","B002");
    //        c.ReportDocument.Subreports(
    //"rptSub").SetParameterValue("key", "value") 
            crConnectionInfo.ServerName = Server1;
            crConnectionInfo.DatabaseName = DataBase;
            crConnectionInfo.IntegratedSecurity = false;
            crConnectionInfo.UserID = user;
            crConnectionInfo.Password = Password;
            crDatabase = crReportDocument.Database;
            crTables = crDatabase.Tables;
            foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
            {
                crTableLogOnInfo = crTable.LogOnInfo;
                crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                crTable.ApplyLogOnInfo(crTableLogOnInfo);
            }
            CrystalReportViewer1.ReportSource = crReportDocument;
            CrystalReportViewer1.Visible = true;
        }
    }

    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 CrystalDecisions.CrystalReports.Engine;

    using CrystalDecisions.Shared;

     

    public partial class Sales : 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;

        CrystalDecisions.CrystalReports.Engine.Table crTable;

     

        protected void Page_Load(object sender, EventArgs e)

        {

            string Server1 = ConfigurationManager.AppSettings["Server"];

            string user = ConfigurationManager.AppSettings["Userid"];

            string Password = ConfigurationManager.AppSettings["Password"];

            string DataBase = ConfigurationManager.AppSettings["DataBase"];

            crReportDocument.Load(Server.MapPath("Sales.rpt"));

            crConnectionInfo.ServerName = Server1;

            crConnectionInfo.DatabaseName = DataBase;

            crConnectionInfo.IntegratedSecurity = false;

            crConnectionInfo.UserID = user;

            crConnectionInfo.Password = Password;

     

            crDatabase = crReportDocument.Database;

            crTables = crDatabase.Tables;

     

            foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)

            {

                crTableLogOnInfo = crTable.LogOnInfo;

                crTableLogOnInfo.ConnectionInfo = crConnectionInfo;

                crTable.ApplyLogOnInfo(crTableLogOnInfo);

            }

     

            CrystalReportViewer1.ReportSource = crReportDocument;

            CrystalReportViewer1.Visible = true;

        }

    }

    My Subreport name is:"SalesHalf.rpt" 
    Plz Help me To Solve This very very very very urgent....

     

     


    This is the code i use for my report.

    Bt i cant able to pass Main report parameter to sub report .... 

    Can anybody explain how to do so ....

    How to load sub report using the above code ....

    Sunday, May 23, 2010 7:35 AM
  • User-319574463 posted

    As per your private message, I have examined your thread. Two immediate comments:

    • I suggest that you never use the terms, "Urgent" or "Very Urgent" - these can be totally unproductive as many of the volunteers who answer on this forum will skip such a thread title.
    • When posting code, I suggest that you use Firefox as then gratuitous blank lines will not be added.
    Monday, May 24, 2010 8:02 AM
  • User-25924017 posted

    Ashraf007,

    As far as I know and I asked to you change report,in Business object (not in .Net), as per the steps in thread link:

    1. Add the parameter that you require for the subreport to the main report. To do this open the Field Explorer window, right click Parameter Fields and select new.

    2.Once you have added your parameter right click the subreport and select Change Subreport Links... This will open the Subreport Links window. Scroll down the Available Fields Treeview in the top left of the window. Under Report fields locate the parameter you added in step one. Select the parameter and press the > button. Click the "Subreport parameter field to use:" dropdownlist and select your parameter from the list. Press the OK button. Now the subreport should use whatever value is in the parameter you added to the main report in step 1.

    Once you have changed the report, only thing you need to do is pass parameter value to main report and subreport will pick it up in asp.net.

    then either you use my code block above to loop through all the parameter fields and set parameter or just simply use

    reportDoc.SetParameterValue(name, value);

    Same I told you in my prev post, did you try this? I hope I am clear enough now.





    Monday, May 24, 2010 12:10 PM