为什么水晶报表不出现也不显示? [英] Why the crystal report not appear and no show?

查看:148
本文介绍了为什么水晶报表不出现也不显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个水晶报表和网页,我想在我的网页中打开水晶报表取决于文本框的值,并且我需要在单击按钮时将这些值发送到水晶报表以显示我的水晶报表。
我尝试了以下代码,并设置了数据源和数据库连接:

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");
            }


推荐答案

我终于找到了解决方案此错误
在将Crystal Reports 13发布到IIS之后为什么会出现空白页?

I found finally the solution for this error Why do I get blank page after publish Crystal Reports 13 to IIS?


  1. 下载并安装运行时适用于Visual Studio 2017的Crystal Reports13。(如果您之前已经做过并且您的应用程序在本地运行,则可能要跳过此步骤。)

  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).

运行时已安装。 Crystal Reports将在本地计算机的位置安装所需的支持文件:
C:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319\crystalreportviewers13

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 Report支持文件夹C:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319\crystalreportviewers13复制到网站的SITE_ROOT\aspnet_client\system_web\4_0_30319文件夹。

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.

4)如果您的网站根目录中没有\aspnet_client\system_web\4_0_30319文件夹。请手动创建它们,然后将crystalreportviewers13复制到其中。

4) If you do not have a \aspnet_client\system_web\4_0_30319 folders in your website's root. Please create them manually and then copy the crystalreportviewers13 into it.

注意:版本号 4_0_30319不是固定的,因为asp.net版本可能会更改。如果4_0_30319不起作用,您可以尝试将此文件夹名称更改为4_6_1069。

Note: the version number '4_0_30319' is not fixed, it might be changed because of asp.net version. You can try to change this folder name to 4_6_1069 if 4_0_30319 not work.

我使用以下解决方案,使用带有参数的存储过程将水晶报表中的参数传递给网站并读取从sqlserver数据库中获取:

I used the following solution to passing parameters from crystal reports using stored procedures with parameters to website and read from sqlserver database :

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;

这篇关于为什么水晶报表不出现也不显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆