简体   繁体   English

为什么水晶报表不出现不显示?

[英]Why the crystal report not appear and no show?

I created a crystal report and webpage, I want to open crystal report in my webpage depends on the textbox value and i need when click the button i send the values to crystal reports to show my crystal report.我创建了一个水晶报表和网页,我想在我的网页中打开水晶报表取决于文本框的值,我需要在单击按钮时将值发送到水晶报表以显示我的水晶报表。 I tried the following code, and I set the data source and connection to database:我尝试了以下代码,并将数据源和连接设置为数据库:

protected void Button1_Click(object sender, EventArgs e)
    {
        rdoc.Load(Server.MapPath("~/RPT/RPT_CASH_RESULT.rpt"));
        SqlCommand cmd = new SqlCommand("GET_ORDER_RESULT_PRINT_CASH", cn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@ORDER_ID", TXTORDERID.Text);
        cmd.Parameters.AddWithValue("@deptid", TXTDEPTID.Text);
        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        sda.Fill(dt);
        rdoc.SetDataSource(dt);
        CrystalReportViewer1.ReportSource = rdoc;
        CrystalReportViewer1.DataBind();

        rdoc.SetDatabaseLogon("DBA", "1234");

    }
}

when click the button its not showing the report only blank screen.当单击按钮时,它不显示报告,只显示空白屏幕。 what to do to show the report where is the mistake?如何显示报告错误在哪里?

I tried another solution but when click print button its not show the crystal report only blank page what to do i tried alot of solutions available in this site and other site???我尝试了另一种解决方案,但是当单击“打印”按钮时,它不显示水晶报告,只显示空白页怎么办我尝试了本网站和其他网站提供的很多解决方案???

protected void BtnCrystal_Click(object sender, EventArgs e)
        {
            if (Session["patientno"] != null && Convert.ToInt32(Session["patientno"]) > 0)
            {
ReportDocument reportDocument = new ReportDocument();

                ParameterFields paramFields = new ParameterFields();
                ParameterField paramField = new ParameterField();
                ParameterField paramField1 = new ParameterField();
                ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
                ParameterDiscreteValue paramDiscreteValue1 = new ParameterDiscreteValue();
                paramField.Name = "@ORDER_ID";
                paramDiscreteValue.Value =Convert.ToInt32(TXTORDERID.Text);
                paramField.CurrentValues.Add(paramDiscreteValue);
                paramFields.Add(paramField);



                paramField1.Name = "@deptid";
                paramDiscreteValue1.Value =Convert.ToInt32(TXTDEPTID.Text);
                paramField1.CurrentValues.Add(paramDiscreteValue1);
                paramFields.Add(paramField1);

                CrystalReportViewer1.ParameterFieldInfo = paramFields;
                reportDocument.Load(Server.MapPath("~/RPT/RPT_CASH_RESULT.rpt"));
                CrystalReportViewer1.ReportSource = reportDocument;
reportDocument.SetDatabaseLogon("DB", "1111","test","DB");
            }

I found finally the solution for this error Why do I get blank page after publish Crystal Reports 13 to IIS?我终于找到了这个错误的解决方案为什么我在将 Crystal Reports 13 发布到 IIS 后得到空白页?

  1. Downloading and installing runtime for Crystal Reports 13 for Visual Studio 2017. (You might want to skip this step if you already did this before and your application is working locally).下载并安装适用于 Visual Studio 2017 的 Crystal Reports 13 运行时。(如果您之前已经执行过此操作并且您的应用程序正在本地运行,则可能希望跳过此步骤)。

  2. Once the runtime is installed.安装运行时后。 Crystal Reports will install the required support files in the location of your local computer: C:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319\crystalreportviewers13 Crystal Reports 将在本地计算机的位置安装所需的支持文件:C:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319\crystalreportviewers13

  3. Copy the entire Crystal Report Support folder C:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319\crystalreportviewers13 to your Website's SITE_ROOT\aspnet_client\system_web\4_0_30319 folder.将整个 Crystal Report Support 文件夹 C:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319\crystalreportviewers13 复制到您网站的 SITE_ROOT\aspnet_client\system_web\4_0_30319 文件夹。

4) If you do not have a \aspnet_client\system_web\4_0_30319 folders in your website's root. 4) 如果您的网站根目录中没有 \aspnet_client\system_web\4_0_30319 文件夹。 Please create them manually and then copy the crystalreportviewers13 into it.请手动创建它们,然后将 crystalreportviewers13 复制到其中。

Note: the version number '4_0_30319' is not fixed, it might be changed because of asp.net version.注意:版本号“4_0_30319”不是固定的,它可能会因为 asp.net 版本而改变。 You can try to change this folder name to 4_6_1069 if 4_0_30319 not work.如果 4_0_30319 不起作用,您可以尝试将此文件夹名称更改为 4_6_1069。

I used the following solution to passing parameters from crystal reports using stored procedures with parameters to website and read from sqlserver database:我使用以下解决方案使用带参数的存储过程将参数从水晶报表传递到网站并从 sqlserver 数据库读取:

ReportDocument reportDocument = new ReportDocument();
                ParameterFields paramFields = new ParameterFields();
                ParameterField paramField = new ParameterField();
                ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
                ParameterDiscreteValue paramDiscreteValue1 = new ParameterDiscreteValue();
                ParameterField parameterField1 = new ParameterField();
                ParameterDiscreteValue parameterDiscreteValue1 = new ParameterDiscreteValue();
                ParameterFields parameterFields = new ParameterFields();
   parameterField1.Name = "@ORDER_ID";
   parameterDiscreteValue1.Value = (object)this.TXTORDERID.Text.ToString();
                            parameterField1.CurrentValues.Add((ParameterValue)parameterDiscreteValue1);
                            parameterFields.Add(parameterField1);

                            ParameterField parameterField2 = new ParameterField();
                            ParameterDiscreteValue parameterDiscreteValue2 = new ParameterDiscreteValue();
                            parameterField2.Name = "@deptid";
                            parameterDiscreteValue2.Value = (object)this.TXTDEPTID.Text.ToString();
                            parameterField2.CurrentValues.Add((ParameterValue)parameterDiscreteValue2);
                            parameterFields.Add(parameterField2);
                            this.CrystalReportViewer1.ParameterFieldInfo = parameterFields;
                            this.CrystalReportViewer1.ReuseParameterValuesOnRefresh = true;
                            this.CrystalReportViewer1.ToolPanelView = ToolPanelViewType.None;
                            reportDocument.Load(this.Server.MapPath("~/RPT/RPT_CASH_RESULT.rpt"));
                            this.CrystalReportViewer1.ReportSource = (object)reportDocument;
                            reportDocument.SetDatabaseLogon("DB", "111");

                            ConnectionInfo connectionInfo = new ConnectionInfo();
                            connectionInfo.ServerName = "server";
                            connectionInfo.DatabaseName = "DBname";
                            connectionInfo.Password = "dbpass";
                            connectionInfo.UserID = "DBuser";
                            connectionInfo.Type = ConnectionInfoType.SQL;
                            connectionInfo.IntegratedSecurity = false;
                            for (int index = 0; index < this.CrystalReportViewer1.LogOnInfo.Count; ++index)
                                this.CrystalReportViewer1.LogOnInfo[index].ConnectionInfo = connectionInfo;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM