如何显示我的Crystal Report不显示

时间:2019-04-13 07:57:38

标签: c# crystal-reports

我尽了我所有的Crystal Report,但是它没有显示在网页中,但是也没有引发任何错误,当我尝试将其托管在IIS中时,它仍然执行相同的操作,但是我的Crystal Report显示在主要报表预览(我使用了数据集)

这是我的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection("Data Source=ONE\\SQLEXPRESS;Initial Catalog=tps;Integrated Security=True");

        DataSet ds = new DataSet();
        DataSetTableAdapters.registrationTableAdapter registration = new DataSetTableAdapters.registrationTableAdapter();

        ReportDocument doc = new ReportDocument();
        doc.Load(Server.MapPath("CrystalReport1.rpt"));
        doc.SetDataSource(ds);
        CrystalReportViewer1.ReportSource = doc;
       CrystalReportViewer1.Visible = true;

    }
}

1 个答案:

答案 0 :(得分:0)

我为我使用此代码及其代码,但是在PortableDocFormat中:

ReportDocument rd = new ReportDocument();
string strRptPath = Server.MapPath("~/") + "Rpts//" + strReportName;

rd.Load(strRptPath);

string userName = ConfigurationManager.AppSettings["UserLogonDb"].ToString();
string password = ConfigurationManager.AppSettings["PasswordLogonDb"].ToString();

rd.SetDatabaseLogon(userName, password);

rd.ExportToHttpResponse(ExportFormatType.PortableDocFormat, 
System.Web.HttpContext.Current.Response, false, "crReport");